Getting a list of all pages in a single PageList request
Permalink
I want to get a list of every non-system, non-aliased page that the current user has permission to view in a single PageList request, but this is as close as I can get:
I have to manually check for viewing permissions on the home Page object then add it to the PageList results array as above. It's the simplest solution I could come up with, but I was wondering if there was a way to do this all in one go?
Thanks!
<?php // Get a list of all viewable pages $objHome = Page::getByID(HOME_CID); $strHomePath = (string) $objHome->getCollectionPath(); $objPl = new PageList(); $objPl->filterByPath($strHomePath, TRUE); $objPl->ignoreAliases(); $arrAllowedPages = (array) $objPl->get(); $objPerm = new Permissions($objHome); if($objPerm->canRead()) array_unshift($arrAllowedPages, $objHome); ?>
I have to manually check for viewing permissions on the home Page object then add it to the PageList results array as above. It's the simplest solution I could come up with, but I was wondering if there was a way to do this all in one go?
Thanks!