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.

Template Questions /

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

Hide Menu if only one page


Go to End


5 Posts   2275 Views

Avatar
pinkp

Community Member, 182 Posts

11 July 2010 at 10:40pm

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 %>

Avatar
3dgoo

Community Member, 135 Posts

13 July 2010 at 7:20pm

For checking if there are multiple Albums you can use:

<% if SingleAlbumView %>
<% else %>

<% end_if %>

Avatar
pinkp

Community Member, 182 Posts

14 July 2010 at 12:20am

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 %>

Avatar
CMRwebadmin

Community Member, 1 Post

6 January 2012 at 10:30pm

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

Avatar
swaiba

Forum Moderator, 1899 Posts

7 January 2012 at 2:16am

Hi CMRwebadmin,

Welcome to the Forums!

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