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

How to hide "Just those pages"..


Go to End


4 Posts   1539 Views

Avatar
wilsonStaff

Community Member, 143 Posts

8 December 2012 at 6:25am

Hi, i have a menu that looks like this, typical SS3 menu:

<ul>
	<% loop Menu(1) %>
		<% if Children %>
			<li class="showSubMenu"><a href="#" title="$MenuTitle">$MenuTitle</a>
				<div class="outerSubMenu" id="$URLSegment">
					<ul>
						<% loop Products %>
							<li>
								<div class="subMenu">
									$IconeProduit.SetWidth(160)<br />
									<a href="$Link" title="$Title">$Title</a>
								</div>
							</li>
						<% end_loop %>
					</ul>
				</div>
			</li>
		<% else %>
			<li><a href="$Link" title="$MenuTitle">$MenuTitle</a></li>
		<% end_if %>
	<% end_loop %>
</ul>

It does what i want i.e.: shows div.submenus only if there are childs and

a href="#" 
=> returns no links, only a clickable event
id="$URLSegment" 
=> hides the submenus using CSS if needed

and there is no child, then there is

<li><a href="$Link" title="$MenuTitle">$MenuTitle</a></li>

Fine. But what if i want SOME CHILDREN NOT SHOW????

Using <% if PageType = ... %> ? => problem is that they are all same pagetype

Using <% if URLSegment = ... %> ? => dont want to mess with that (user can add child as needed)

Using <% if ChildrenOf(..) = ... %> => does that exist? If so, how to implement?

Thanks!

Avatar
Willr

Forum Moderator, 5523 Posts

8 December 2012 at 4:25pm

Can you not just untick the 'Show In Menus' option in the CMS? This will hide the page from <% loop Children %> and any other feeds.

Avatar
wilsonStaff

Community Member, 143 Posts

8 December 2012 at 4:53pm

nope i cant. because if i do, this:

<% loop ChildrenOf(the-page-i-dont-want-children-to-show)%>

wont return anything...

Avatar
kaanuni

Community Member, 22 Posts

20 December 2012 at 3:45am

Well you can always create your own 'soft' don't show in menus custom field in your page model and then check it with an if block in the loop in your template .