Jump to:

22983 Posts in 11709 Topics by 2827 members

General Questions

SilverStripe Forums » General Questions » Show only on first level pages not in sub pages?!

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

Page: 1
Go to End
Author Topic: 572 Views
  • suntrop
    Avatar
    Community Member
    131 Posts

    Show only on first level pages not in sub pages?! Link to this post

    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

  • ampedup
    Avatar
    Community Member
    133 Posts

    Re: Show only on first level pages not in sub pages?! Link to this post

    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.

  • suntrop
    Avatar
    Community Member
    131 Posts

    Re: Show only on first level pages not in sub pages?! Link to this post

    Yes it helps Thanks!

    572 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.