Simple PageList

Simple PageList

When you need a list of pages you don't always have to use the concrete5 PageList object.


Snippet by Ollie / / Comments / Difficulty 
Simple PageList

When we need to grab a list of pages under another page we tend to think of the PageList object first.

As powerful as the PageList object is, it may be more than you need.

This code returns an array of all children page IDs under any given page object. For some use cases it's actually better than using the PageList object, for example, if you need to iterate through pages in their true sitemap order.

In this snippet the page object is obtained using a page's collection ID ($cID).

$children = array();
$children = page::getByID($cID)->getCollectionChildrenArray();

Join the conversation

comments powered by Disqus