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.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

General Questions /

General questions about getting started with SilverStripe that don't fit in any of the categories above.

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

Problem with this code to show menu links


Go to End


2 Posts   1055 Views

Avatar
Jookl

Community Member, 2 Posts

11 April 2014 at 10:48pm

Hi,

I have a problem as 3rd level page links don't appear in menu on 1st level page, but only on 2nd level page.

We have 2 side menus (one for 2nd level pages and one for 3rd level pages) and we would like for both be visible on 1st level page.

This is the code we are using:

<div id="Sidebar">
<% if Menu(2) %>
<div class="content well" style="padding: 8px 0;">
<ul class="nav nav-list">

<% control Menu(3) %>
<li class="$LinkingMode">
<a href="$Link">
<i class="icon-file <% if LinkingMode == "current" %>icon-white<% end_if %>"></i>
$MenuTitle.XML
</a>
</li>
<% end_control %>
</ul>
</div>
<% end_if %>
<%-- Enable Social Buttons here --%>
<%-- include SocialButtons --%>

</div>
<div id="Sidebar">
<% if Menu(2) %>
<div class="content well" style="padding: 8px 0;">
<ul class="nav nav-list">

<% control Menu(2) %>
<li class="$LinkingMode">
<a href="$Link">
<i class="icon-file <% if LinkingMode == "current" %>icon-white<% end_if %>"></i>
$MenuTitle.XML
</a>
</li>
<% end_control %>
</ul>
</div>
<% end_if %>
<%-- Enable Social Buttons here --%>
<%-- include SocialButtons --%>

</div>

Any suggestion?

Avatar
martimiz

Forum Moderator, 1391 Posts

15 April 2014 at 12:46am

Hi Jookl

Please don't crosspost - it won't get your question answered any faster, but it might lead to someone putting effort into answering your other post as well. I've removed the other post (reference: 49903#post346917).

As to your question:
You'll find that on the SilverStripe docs site, the first level page also doesn't have a third level menu: See here: http://doc.silverstripe.org/framework/en/.

Also you'll see that for each level 2 page the level 3 menu will be different.

That's because a third level menu is ambiguous in a page hierarchy: say a page on level 1 has multiple children (level 2). Some of these children have their own set of children (level 3). How would page 1 'know' which level 3 pages to show?

So in your situation, what would you want to display in your menu(3) for your level 1 page?