Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

General Questions /

General questions about getting started with SilverStripe that don't fit in any of the categories above.

Moderators: martimiz, Sean, biapar, Willr, Ingo, swaiba, simon_w

Create multiple column layouts in backend


Reply


5 Posts   747 Views

Avatar
danzzz

Community Member, 175 Posts

13 March 2012 at 6:54am

hi,

there are some old forum posts about this thema ... but I want to ask you again, may some of you have new innovative solutions or may know a module to do this:

Whats the best way to give a user the possibility to create multiple columns in backend?
For example I want a layout with a 100% col, then 3 cols, then 2 cols, then again a 100% col. In each col I want to insert just HMTL content (HTMLText).

And I dont mean just to give him some page types with different layouts, thats not very flexible ...

happy ss'ing :-)

Avatar
kinglozzer

Community Member, 175 Posts

20 March 2012 at 10:41pm

I'm not entirely sure what you mean by "100% col, then 3 cols, then 2 cols, then again a 100% col." - as in 100% at the top, 3 underneath, 2 under that and then 100% at the bottom?

Could you not achieve this by adding extra HTMLEditor fields or TextArea fields for each of the columns? Then styling them in your template - you could use a set of 'if' statements to achieve different layouts based on which columns are filled in.

Unless someone has a better idea?

Avatar
danzzz

Community Member, 175 Posts

21 March 2012 at 11:10am

hi

"as in 100% at the top, 3 underneath, 2 under that and then 100% at the bottom?" => YES I mean like that

The user should can create multiple column layouts without using page types. All the needed HTML code should stored
just in $Content field ... so it's more a JS thing I think ...

Avatar
novaweb

Community Member, 115 Posts

21 March 2012 at 11:46am

To achieve this in the past, I have created one page type for each of the different required layouts, then coded CSS accordingly

ie)

TwoColumnPage.php
ThreeColumnPage.php

Then the user just selects which layout they desire by picking the corresponding page type.

Multiple Content Areas may be necessary as pointed out by kinglozzer

Cheers,
Josh

Avatar
nimesodelta

Community Member, 21 Posts

23 March 2012 at 3:41pm

I use CSS3 for doing this now.

http://www.w3schools.com/css3/css3_multiple_columns.asp

Or I just create new HTMLEditorField for each column.

You could create a has_many rule to a object like

<?php
class Column extends DataObject {

   static $db = array(
      "Content" => "HTMLText",
   );

   public static $has_one = array(
      "Page" => "Page"
   );
}

And then use a complexTableField to create as many columns as you want for each page... maybe. You will need to create some funky Template loops and also clever CSS or javascript to float and set widths of each column.

Hope this helps