Jump to:

17452 Posts in 4473 Topics by 1971 members

Archive

SilverStripe Forums » Archive » Side Content

Our old forums are still available as a read-only archive.

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

Page: 1 2
Go to End
Author Topic: 2981 Views
  • Todd
    Avatar
    31 Posts

    Side Content Link to this post

    Hi,

    I've created a web page that has both main content and side content.

    I was wondering how to best implement this in CMS.

    Many thanks.

  • trevor
    Avatar
    53 Posts

    Re: Side Content Link to this post

    What is it that you wish to show in the side content is it mainly for navigation to other areas of the site?

  • Todd
    Avatar
    31 Posts

    Re: Side Content Link to this post

    Hi Trevor,

    Thanks for the quick response.

    No, not navigation, just extra content. For example, I created a contact page in which the main area is a contact form and the right-side area has address, phone and email information, among other things (a 3 column layout).

    Todd

  • trevor
    Avatar
    53 Posts

    Re: Side Content Link to this post

    Ok so in the normal Page.ss template this outputs $Content which is the field in the database that stores the main content so what you will need to do is either add a sidecontent field to your page type or the individual fields for address, email, phone etc. and then create a template for your page type and output the fields.

    Its simpler to just have a template under the layout folder which is the same name as your page type providing this fits with what you want to do. I only say this because I made a mistake of creating an additional template for each page type which in certain instances was not necessary.

    HTH

    Trevor

  • Todd
    Avatar
    31 Posts

    Re: Side Content Link to this post

    Hi Trevor,

    First off, I just want to thank you for the help you're providing.

    I think I'm pretty good with the template aspect, I guess I was more curious as how to implement this in the CMS. For example, would I need to create a 'SideContent' pagetype that would we accessible to each 'Parent' pagetype that I designate as 3 columns? What I mean is, would I create a pageholder pagetype, let's say called 3ColHolder.php, then create a 3ColPage pagetype (3ColPage.php) that is a child to the pageholder?

    Am I making this too complicated?

    Thanks,

    Todd

  • trevor
    Avatar
    53 Posts

    Re: Side Content Link to this post

    No Problem, I have received help from others and so if I can then pass on that help this is what hopefully will help the community.

    Also if I see what others a trying to do it helps see other possibilities so indirectly this helps me too.

    You could do what you are saying and then in the template for the 3colholder access the 3colpage(s) and display this in the side. this will mean you won't need to add any additional db fields as you will just use the $Content from the 3colpage entries created. So in the cms you would create a 3colholder and then underneath create 3colpage or pages.

    You could just have one include file that did this iterating the Children of the page to display in the side column and use this in whichever pagetype you require.

    I hope I'm helping here maybe if you look at the way the menus work in the example system then this will clarify how to do it. It all depends on what you are trying to achieve for the content.

    Regards

    Trevor

  • dio5
    Avatar
    Community Member
    501 Posts

    Re: Side Content Link to this post

    I'd do it like this:

    in the Page class I would do

    static $db = array(
       "SideContent" => "Text"
    )
    function getCMSFields()
       {
          $fields = parent::getCMSFields();
          $fields->addFieldToTab('Root.Content.Side', new HtmlEditorField(SideContent', 'Side Content'));
          return $fields;
       }

    And there you have it.

  • Todd
    Avatar
    31 Posts

    Re: Side Content Link to this post

    Hi Trevor, Dio5,

    Thanks for the info. Dio5, the information you provided worked like a charm. I thank you both for your time and effort.

    Todd

    2981 Views
Page: 1 2
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.