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.

Template Questions /

Creating unique sidebar info per page


Reply


3 Posts   629 Views

Avatar
bpdons

Community Member, 2 Posts

28 November 2011 at 1:22pm

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?

Regards,
Ben

Avatar
martimiz

Forum Moderator, 1132 Posts

30 November 2011 at 12:38am

Edited: 30/11/2011 12:40am

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?)

Martine

Avatar
bpdons

Community Member, 2 Posts

30 November 2011 at 2:31am

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