Jump to:

23487 Posts in 18996 Topics by 2878 members

General Questions

SilverStripe Forums » General Questions » Customize my content with styled boxes

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

Page: 1
Go to End
Author Topic: 1086 Views
  • suntrop
    Avatar
    Community Member
    131 Posts

    Customize my content with styled boxes Link to this post

    Hi all.
    I just started using CMS and I am not that familiar on how to customize them. So, now I'd like to know how to get some "flexible" content in SS.
    A quick example of what I mean by that.
    Lets say I want several (styled) DIVs in my content (like that for example: http://www.charitywater.org/donate/).
    My first idea was to create a new page with 10 (in this case and example above) new fields. 5 for the photos and 5 for the text. But that is extremely inflexible, because I can't add more or less items/divs. I am stuck at 5!

    It is pretty awful trying that just with the content editor Especially if the divs start getting more complex and you want to add some JS animations to it (hide text, hover images, slide out ...).

    I hope you get what I want to achieve

    How do you create pages like that? Do you have a dozen pages, all for just one content page? Do you write the code directly into the HTML editor?

    You see, I don't have a clue what to do

  • swaiba
    Avatar
    Forum Moderator
    1792 Posts

    Re: Customize my content with styled boxes Link to this post

    I would create a new Page type PageXYZ (so code/PageXYZ.php and templates/Layout/PageXYZ.ss) and then each of these as a templates/Includes/MyStyledBoxXYZ.ss and then edit the PageXYZ.ss to <% include MyStyledBoxXYZ %>.

    Or maybe you could look at doing something similar with Widgets and instead of being relegated to the "side bar" you could use them in the main area and then you could control them point and click style in the CMS.

    Generally I use the page content for the stuff at the top of the page and then everything else is in the template and normally controlled (behaviour and content) from Dataobjects that are managed by ModelAdmin.

    Not saying either of these are the best, but hope it helps...

    Barry

  • suntrop
    Avatar
    Community Member
    131 Posts

    Re: Customize my content with styled boxes Link to this post

    Barry, thanks for your answer.
    Sorry, but I can't follow your first idea. Does it has any different to a "normal" page type?

    Can you suggest a widget for my content?
    I've read some sentences about the DataobjectManager. I think I have to read more about it.

    I had some insight into another CMS yesterday. There I was able to create new fields and add the same fields as often as I need them. Maybe something like that is possibly in SS?

    Thanks and bey
    suntrop

  • swaiba
    Avatar
    Forum Moderator
    1792 Posts

    Re: Customize my content with styled boxes Link to this post

    I'd recomend you read through...

    http://doc.silverstripe.org/...

    especially...

    http://doc.silverstripe.org/page-types

  • martimiz
    Avatar
    Forum Moderator
    1086 Posts

    Re: Customize my content with styled boxes Link to this post

    Hi
    Your first idea, adding a fixed couple of fields to the page, is indeed a bit inflexible. What you could do (aside from using widgets) is define a has_many relationship on your page. Suppose you created some DataObject class for styled boxes - lets call it 'StyledBox'.

    So now in your Page class, you do:

    static $has_many = array(
       'MyStyledBoxes' => 'StyledBox'
    );

    Your StyledBox class might look something like this:

    class StyledBox extends DataObject{

       static $db = array(
          'Title' => 'Varchar()',
          ...
       );

       static $has_many = array(
          'MyPage' => 'Page'
       );

    }

    Now you can add as many StyledBox objects to the page as you wish. For the backend, in your Page's getCMSFields() function you would define a ComplexTableField for that purpose - or a DataObjectManager if you so wish.

    In your page template you do something like:

    <% control MyStyledBoxes %>
       <h1>$Title</h1>
       ...
    <% end_control %>


    I agree with swaiba that I would create a new pagetype for this. Hope this helps some more,

    Cheers, Martine

  • suntrop
    Avatar
    Community Member
    131 Posts

    Re: Customize my content with styled boxes Link to this post

    Hi Martine.
    Sounds like it is what I need Two questions …

    1. What do you mean by 'Now you can add as many StyledBox objects to the page as you wish'?
    2. The ComplexTableField-thing is something I can't get my head wrapper around it. The doc-page is too techy for me

    Hope you can help. Thanks a lot!

    suntrop

    1086 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.