Forum

Thread tagged as: Question, Problem, Configuration

Fetching region from another page

I have a series of pages which act as listing pages for blog sections. Each of these pages has it's own region called Page Banner. When you go into one of the posts from the sections, I want to carry over the region from the parent section page, which is just a normal page with the listing output on them. All the actual post pages use the post.php from my /news directory. I am trying to use something like:

perch_content_custom('Page Banner', array(
         'page'=>'/workout_diary.php',
));

But I am getting this error: No matching content regions found. Check region name (Page Banner) and page path options. - doubled check and it's definitely the right page file. Is it something to do with the fact that this is on my post.php which is inside a directory of news, and the workout diary page is just a standard page not within the same dir?

Mathew Doidge

Mathew Doidge 2 points

  • 4 years ago
Drew McLellan

Drew McLellan 2638 points
Perch Support

Is workout_diary.php in the root of your site?

Suddenly realised that what I'm actually referencing here is the page master template, rather than the page itself — I think... Sorted it with:

$section = perch_blog_post_field(perch_get('s'), 'sectionSlug', true);

if ($section == 'workout-diary') {
    perch_content_custom('Page Banner', array(
        'page'=>'/workout-diary',
        'template' => 'sub_banner.html',
    ));
} elseif ($section == 'news') {
    perch_content_custom('Page Banner', array(
        'page'=>'/news',
        'template' => 'sub_banner.html',
    ));
}
Drew McLellan

Drew McLellan 2638 points
Perch Support

Or you could do:

$section = perch_blog_post_field(perch_get('s'), 'sectionSlug', true);

perch_content_custom('Page Banner', [ 
    'page' => '/'.$section, 
    'template' => 'sub_banner.html', 
]);

Damn, yes I could. Over complicating it, really appreciate the tip, Drew.