Jump to:

17452 Posts in 4473 Topics by 1971 members

Archive

SilverStripe Forums » Archive » Displaying pages where "Show in menus?" unticked

Our old forums are still available as a read-only archive.

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

Page: 1
Go to End
Author Topic: 1347 Views
  • gakenny
    Avatar
    Community Member
    153 Posts

    Displaying pages where "Show in menus?" unticked Link to this post

    Hello,

    On my current project I have created Staff Pages. Instead of clicking these items for more details, i am listing all details in the template for the Page Holder. Becauce of this, I do not want these items to list in the menu at the side of the page.

    However if I untick the "Show in menus?" option for each page, the details are not shown by the Page Holder template. I am using <% control Children %> to iterate through each of the Staff pages.

    Can anyone assist?

    Cheers,

    Gary

  • Sean
    Avatar
    Forum Moderator
    921 Posts

    Re: Displaying pages where "Show in menus?" unticked Link to this post

    Hi there,

    By default, Children displays pages if the field ShowInMenus is 1.

    You can override this behaviour by making your own custom control. On the class for your staff pages, or on Page (dependent on how you've setup your project), you can make a function like this:

    function StaffPages() {
    return DataObject::get('StaffPage', "ParentID = $this->ID");
    }

    Then replace <% control Children %> with <% control StaffPages %> - bear in mind this is assuming you have StaffPage page types assigned to your staff pages. Just change the first parameter to 'Page' if you want to get any page type as children instead.

    Hope this helps!

    Cheers,
    Sean

  • gakenny
    Avatar
    Community Member
    153 Posts

    Re: Displaying pages where "Show in menus?" unticked Link to this post

    Thanks as always, Sean!

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