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.

Archive /

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

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

Displaying pages where "Show in menus?" unticked


Go to End


3 Posts   1719 Views

Avatar
gakenny

Community Member, 153 Posts

22 October 2007 at 2:42pm

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

Avatar
Sean

Forum Moderator, 922 Posts

22 October 2007 at 8:11pm

Edited: 22/10/2007 8:16pm

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

Avatar
gakenny

Community Member, 153 Posts

22 October 2007 at 8:50pm

Thanks as always, Sean!