Page list block - how do I create a list of ALL pages in ALL tiered subdirectories
PermalinkI'm new to C5 so forgive me for my ignorance... I'm trying to rebuild my sitehttp://www.romanticretreats.co.uk using C5. How do I create a page list block that displays not only the pages from the directories below it but also from any directories lower down?
For example, the pagehttp://www.romanticretreats.co.uk/romantic-cottages.php... on the current site shows ALL cottages, the pagehttp://www.romanticretreats.co.uk/romantic-cottages/north-england.p... shows only those in North England andhttp://www.romanticretreats.co.uk/romantic-cottages/north-england/t... shows only those in The Lake District. The actual cottages each have a page in that particular directory.
Is this also possibly in C5? How would I do this?
Thanks for your help,
Konrad
You have a few options here:
* Instead of pulling in all pages beneath a certain page, filter by page type and make sure all the pages below a certain page are of that page type.
* Don't have sub-directories. You can use the free "Force Single Sublevel" addon to enforce this automatically so users don't have to remember.
* Use the autonav block instead, and customize its output to look like your page list. You can try using my new spiffy easier-to-customize autonav template if you want to go this route:
https://github.com/jordanlev/c5_clean_block_templates/blob/master/au...
But I know these are all sub-optimal solutions -- would be nice if this was addressed in the core system some time.
Chad
Chad
The only downside is if there are a *lot* of pages in the section you're dealing with then it becomes quite burdensome to remember to check that attribute for every page.
$pl = new PageList(); $pl->filterByPath($page->getCollectionPath()); $pages = $pl->get();
Will return all children. filterByPath returns all children by default, which works pretty well, because it's path-based. It could be slightly performance intensive since it's a like DB query, but we haven't noticed a problem searching under large nodes on our site, which is pretty large.
You can see this functionality by searching in the dashboard > sitemap > page search, and choosing "beneath page" and selected "search all users under selected page."
Hope this helps!
Is this something you'd accept as a pull request if I added this option to the built-in page list block? It comes up in the forums quite a bit.
Each page has to be allowed to shown in the page list, not excluded.
When you add your page list block set options in pop up to allow all and everywhere.
Pick Alphabetical or site map order.
See attached.
Hope that helped