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

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


Reply


3 Posts   708 Views

Avatar
suntrop

Community Member, 131 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, 133 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, 131 Posts

19 June 2010 at 3:20am

Yes it helps :-) Thanks!