Search code examples
concrete5

Concrete5: get pages in the root of the website


I want to display all website pages on a single page in a tree structure (sort of like the existing sitemap). I can get a page by its ID, I can get children of a page, but how do I find pages that are in the root and do not have a parent? In other words, how do I get the first level on the tree?

EDIT: I found out that home page has ID = 1, and dashboard ID = 2. I hope it is like this in every installation of Concrete5...


Solution

  • OK, I found the answer in the code. This is how you get home page:

    $home = Page::getByID(HOME_CID, 'RECENT');
    

    And this is how you get the children:

    $children = $home->getCollectionChildren();