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

Show only on first level pages not in sub pages?!


Go to End


3 Posts   1050 Views

Avatar
suntrop

Community Member, 141 Posts

17 June 2010 at 10:05pm

My website has a sidebar with the 2nd level menu items related to that category.
But if the user is on a 1st level page (example.com/page-name/) where are no sub pages there is nothing and it looks a bit ugly :)
I want to show all first level menu items. But how can I detect if it's a first level with no sub pages?

i think it is really simple, but can't get my head around it :)

Avatar
3dgoo

Community Member, 135 Posts

18 June 2010 at 1:25pm

Howdi,

Where you have your sub menu you have something like this:

<% control Menu(2) %>
...


...
<% end_control %>

What you can do is have an if statement around it, with an else afterwards:

<% if Menu(2) %>

<% control Menu(2) %>
...

...
<% end_control %>

<% else %>

<% control Menu(1) %>
...

...
<% end_control %>

<% end_if %>

Hope that helps.

Avatar
suntrop

Community Member, 141 Posts

19 June 2010 at 3:20am

Yes it helps :-) Thanks!