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

Navigation


Reply


4 Posts   811 Views

Avatar
Mackodlak

Community Member, 95 Posts

1 July 2011 at 9:01pm

Hello, yet again.
My new problem is this... in sitetree in menu(1) level I have 7 different pages, and then they span on.
The thing is, when using navigation:

<% control Menu(1) %>   
      <li><a href="$Link" title="Go to the $Title.XML page" class="$LinkingMode"><span>$MenuTitle.XML</span></a></li>
<% end_control %>

I need it to show first 4 pages on one place and then 3 pages on another (so there will be 2 navbars)
Which function fo I have to override to be able to do this?

Thank you

Avatar
stallain

Community Member, 61 Posts

3 July 2011 at 7:35am

Edited: 03/07/2011 7:36am

Hi, I've already done this, but without creating any function.

A first solution would be to have two different classes for your level(1) pages. Let's say, for instance the "Menu1" page type, and the "Menu2" page type. Then, for your first navigation bar, your code would be :

<% control Menu(1) %>
<% if ClassName = Menu1 %>
<a href=$Link>$Title</a>
<% else %>
<% end_if %>
<% end_control %>


... and same thing with <% if ClassName = Menu2 %> for your second nav bar.

A second solution would be to create a tickable box in the cms that the user checks if he wants the page to show up in the first nav bar. Let's call it "ShowInMenuOne". Your code becomes :

<% control Menu(1) %>
<% if ShowInMenuOne %>
<a href=$Link>$Title</a>
<% else %>
<% end_if %>
<% end_control %>


for the first nav bar and

<% control Menu(1) %>
<% if ShowInMenuOne %>
<% else %>
<a href=$Link>$Title</a>
<% end_if %>
<% end_control %>


For the second nav bar.

I'm sure it's not the most intelligent way to handle your problem, but it works !

Avatar
Mackodlak

Community Member, 95 Posts

28 July 2011 at 12:08am

Hey,
thanks for the answer, it helped.
It does work, it just doesn't feel right, but ok, I guess whatever gets the job done.

Cya mate!

Avatar
zenmonkey

Community Member, 528 Posts

28 July 2011 at 7:20am

Similar to stallain's solution, but I'd add a field to the Page class for the two menu's that way you can filter on that field instead of class name, this will allow you to set it on any page type. Slightly more flexible because you're not reliant on having specific page-typesbuild your nav