Jump to:

3393 Posts in 976 Topics by 852 members

Template Questions

SilverStripe Forums » Template Questions » Hide Menu if only one page

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

Page: 1
Go to End
Author Topic: 1336 Views
  • pinkp
    Avatar
    Community Member
    168 Posts

    Hide Menu if only one page Link to this post

    How can I hide the menu if there is only one page.
    It is currently set to only show Menu2 if it is currently on the Image Gallery page.
    But there is currently only one page and I want the menu to be hidden until the second album / page is added.

    Page.ss

    <% if LinkOrCurrent = current %>
    <% if is_a(ImageGalleryPage) %><div id="Sidebar" class="typography">
             <div class="sidebarBox">
    <ul id="Menu2">
                <% control Albums %>
                   <li class="$LinkingMode"><a class="$LinkingMode" href="$Link" title="$AlbumName" alt="$AlbumName">$AlbumName</a></li>
                <% end_control %>
                </ul>
                <div class="clear"></div>
             </div>
          </div><% end_if %><% end_if %>

  • ampedup
    Avatar
    Community Member
    133 Posts

    Re: Hide Menu if only one page Link to this post

    For checking if there are multiple Albums you can use:

    <% if SingleAlbumView %>
    <% else %>

    <% end_if %>

  • pinkp
    Avatar
    Community Member
    168 Posts

    Re: Hide Menu if only one page Link to this post

    Perfect thanks!!!

    For any one else:

    <% if LinkOrCurrent = current %>
    <% if is_a(ImageGalleryPage) %><% if SingleAlbumView %><% else %>
    <div id="Sidebar" class="typography">
             <div class="sidebarBox">
    <ul id="Menu2">
                <% control Albums %>
                   <li class="$LinkingMode"><a class="$LinkingMode" href="$Link" title="$AlbumName" alt="$AlbumName">$AlbumName</a></li>
                <% end_control %>
                </ul>
                <div class="clear"></div>
             </div>
          </div><% end_if %><% end_if %><% end_if %>

  • CMRwebadmin
    Avatar
    Community Member
    1 Post

    Re: Hide Menu if only one page Link to this post

    Hi guys is there a way I can hide the menu on a particular page so that it can only be accessed via the link only please.

    e.g. if the link to that page is "www.cm-research.com/UKsurvey" I want it so that the age can only be accessed by the link but can not be seen on the menu.

    I have managed to get the particular page to appear on the menu, but I can't seem to figure out how to get the menu of the particular page.

    any help would be greatly appreciated.

    I am new to Silverstripe so please bare with me.

    Many thanks in advance

  • swaiba
    Avatar
    Forum Moderator
    1769 Posts

    Re: Hide Menu if only one page Link to this post

    Hi CMRwebadmin,

    Welcome to the Forums!

    How about goign to the page in question, the Behaviour tab and then unchecking "Show in menus?"

    1336 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.