Jump to:

3439 Posts in 1028 Topics by 869 members

Template Questions

SilverStripe Forums » Template Questions » page control to list all pages

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

Page: 1
Go to End
Author Topic: 2667 Views
  • Amir Mostofi
    Avatar
    Community Member
    59 Posts

    page control to list all pages Link to this post

    I have a simple question. Is there a page control that can be used to list all the pages within the CMS whether the option ‘show in menus?’ is checked/unchecked in the tab panel behaviour?

    What I'm after is something like <% control menu(1) %> which lists all level 1 pages which have ‘show in menus?’ checked. Instead I want a control that lists all pages regardless of the state of ‘show in menus?’.

  • Ben Gribaudo
    Avatar
    Community Member
    181 Posts

    Re: page control to list all pages Link to this post

    Hello,

    I guess you could start by doing a DataObject::get that fetches the top-level pages (those with a ParentID == 0), then use AllChildren() to get their children, as desired.

    (AllChildren() works just like Children() except that it includes the "don't show in menu" children in its output. You can use it just like Children(), for example: <% control AllChildren %>).

    Hope this helps,
    Ben

  • Amir Mostofi
    Avatar
    Community Member
    59 Posts

    Re: page control to list all pages Link to this post

    I had a feeling that you had to define your own controller. Ben thank you for confirming that and the suggestion.

  • motoservo
    Avatar
    Community Member
    24 Posts

    Re: page control to list all pages Link to this post

    Why not just pass a message to DataObject::get to get all objects of type 'Page'?

  • Ben Gribaudo
    Avatar
    Community Member
    181 Posts

    Re: page control to list all pages Link to this post

    Good question! That might work. I'm not sure if original poster wants all pages on the site or just all level one pages.

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