Forum

Thread tagged as: Question

Aggregate Regions created from Master

Me again. Just wondering if there's a way to aggregate the regions (created dynamically from a master) from sub-pages into its top-level parent?

Basically I want the top level parent page to show all the content combined from each of its sub-pages. I looked into the "Sharing pages" documentation, but it seems I can only do this if the subpages were created statically, rather than dynamically from a Master page, since the Perch regions all have the same name when created from a Master.

Thanks,

Chad Tiffin

Chad Tiffin 0 points

  • 6 years ago
Drew McLellan

Drew McLellan 2638 points
Perch Support

You can use perch_content_custom() with a wildcard in the page option:

perch_content_custom('Region name', [
    'page' => '/parent-page/*',
]);

Awesome thanks!

I've used this code to compile all of the Packages pages into one page (all my pages are in the same directory, even subpages. The Package pages are created from a master page:

perch_content_custom('Packages_Master', [
  'page' => '/*',
]);

It seems to have also included my contact page, which has a region that's named 'Contact', and is neither a subpage of Packages nor was it created from a Master page... none of my other unrelated pages were included, just the contact page and I can't figure out why.

Found a workaround by renaming only the pages I wanted with a pre-fix and including that with a wildcard.