Jump to:

3393 Posts in 976 Topics by 852 members

Template Questions

SilverStripe Forums » Template Questions » How to hide "Just those pages"..

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

Page: 1
Go to End
Author Topic: 463 Views
  • wilsonStaff
    Avatar
    Community Member
    142 Posts

    How to hide "Just those pages".. Link to this post

    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!

  • Willr
    Avatar
    Forum Moderator
    5462 Posts

    Re: How to hide "Just those pages".. Link to this post

    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.

  • wilsonStaff
    Avatar
    Community Member
    142 Posts

    Re: How to hide "Just those pages".. Link to this post

    nope i cant. because if i do, this:

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

    wont return anything...

  • kaanuni
    Avatar
    Community Member
    22 Posts

    Re: How to hide "Just those pages".. Link to this post

    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 .

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