Jump to:

3444 Posts in 1030 Topics by 871 members

Template Questions

SilverStripe Forums » Template Questions » Creating unique sidebar info per page

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

Page: 1
Go to End
Author Topic: 516 Views
  • bpdons
    Community Member
    2 Posts

    Creating unique sidebar info per page Link to this post

    Hi there,
    I'm hoping someone out there may be able to point me in the right direction.

    A site i'm currently working on has 3 different template designs on the inner pages.
    Each Template requires a sidebar that has content (entered via its own tab in cms) called "Quick Links", which is a user added one-many list using ModelManager.

    I originally set this up in the overall Page.php class and could include it in all 3 templates.
    This is not how the client originally intended the quick links to work, and now request that each page have its own unique quick links sidebar.

    By moving the ModelManager to the template class name, slightly fixes this problem, but multiple pages can use the same template,. but expect to have a different quick links info in their sidebar.

    Is this at all possible to implement?


  • martimiz
    Forum Moderator
    1086 Posts

    Re: Creating unique sidebar info per page Link to this post

    Hi, welcome to the forums

    Clients... If you want quicklinks to be created separately for each page, one way to go would be to create a 'QuickLink' object that holds the data for each link, simply have the page have a has_many relation QuickLinks, and than use a table field like the ComplexTableField or the DataObjectManager to create links on each page.

    static $has_many = array('QuickLinks' => 'QuickLink');

    <% control QuickLinks %>
    <% end_control %>

    If you want to reuse links, that would imply a many_many relation and, depending on the situation, a different setup... ( ManyManyComplexTableField? Modeladmin/ajshort itemsetfield module?)


  • bpdons
    Community Member
    2 Posts

    Re: Creating unique sidebar info per page Link to this post

    Thank you for the quick response martimiz,

    Followed your instructions and it worked perfectly.
    I was on the verge of hard coding 5 sidebars, client can now say "See I told you it was possible".

    Used the DataObjectManager to add the data, and then displayed my ordered list using the regular <% control QuickLinks %>.

    If you're ever in Melbourne, I owe you a beer

    Thanks again

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.