Jump to:

3447 Posts in 1032 Topics by 872 members

Template Questions

SilverStripe Forums » Template Questions » Iterate over Children that are not shown in the Menu

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

Page: 1
Go to End
Author Topic: 2432 Views
  • Andre
    Avatar
    Community Member
    126 Posts

    Iterate over Children that are not shown in the Menu Link to this post

    Hi, I have a Page with lots of first level Children. The Page is iterating over all its children to show a small Teaser an a link (like the Staffmembers Tutorial).My Problem now is, that I don't want these Children to be shown in the Menu (only if its definitivly switched on). So all Children are by default "ShowInMenus" => 0.

    But, if I use <% control Children %> in my template only those Children are taken which are aktivated to be shown in the menu.

  • SilverRay
    Avatar
    Community Member
    167 Posts

    Re: Iterate over Children that are not shown in the Menu Link to this post

    If I understand you correctly:

    <% control AllChildren %>

    See http://doc.silverstripe.com/doku.php?id=built-in-page-controls

  • Andre
    Avatar
    Community Member
    126 Posts

    Re: Iterate over Children that are not shown in the Menu Link to this post

    That is exactly what i was looking for, many thanks.

  • camfindlay
    Avatar
    Forum Moderator
    148 Posts

    Re: Iterate over Children that are not shown in the Menu Link to this post

    I have a similar problem but a bit more complicated I think,

    I have a holder page with articles and I am showing a teaser for the articles on the holder page. The articles however are only fully accessible when a user signs up and is logged in. I have set the access of the individual articles to "Logged-in users".
    The problem I have is that when I am NOT logged in the holder page will not show the teasers for the articles at all (assuming because the are bound by the access rule)

    Is there a way to have a holder page display its children pages even if they are locked by the security methods?

    At first I though the <% control AllChildren %> method above would work but it appears that only works for pages not shown in the menu system.

    Will I need to perhaps write an action in the Holder page's controller to achieve this?

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