Probably pushing my luck a little bit here with Perch standard, I'm trying to combine a specific block (logos) from a group of pages.
I'm grabbing the regions from all of the children of the products page.
Then switching the page content template to one that only shows the block I want.
It's kinda working but I'm getting two copies of the block for some pages and not others?
PHP
- <?php
- ////////Products AS NAVIGATION/////////
- $pages = perch_pages_navigation([
- 'skip-template' => true,
- 'from-path' => '/products',
- 'levels' => 1,
- 'hide-extensions' => false,
- ]);
- if(!empty($pages)){
- array_multisort(array_column($pages, 'pageTreePosition'), SORT_ASC, $pages);
- $paths = array_column($pages, 'pagePath');
- foreach ($paths as $path) {
- perch_content_custom(array('Page Content'), array(
- 'page' => $path,
- 'template' => '_homepage/home_product_blocks.html',
- 'each'=>function($item) {
- $item['title'] = perch_page_attribute('pageTitle',
- ['_id' => $item['_pageID']], true);
- return $item; },
- ));
- }
- }
- ?>
The pattern I've noticed is that if the logos block is first in the list on the page builder (ie no other different blocks before it), the block is shown twice?