Forum

Thread tagged as: Question

Master Pages - possible to allow for special case regions?

The site I'm building uses the same structure for each internal page, so I've set up a master page for this with 2 regions for the main content area & sidebar. Each page is set to reference the master page.

I'm confused about how to handle a few special case pages, where there is some extra content. For example, one page has a table at the bottom, and another has a slider.

Is there a way of adding extra regions just to particular pages, while still referencing a master page (either by conditionally outputting the regions in the master template, or adding some code to the child page where the master page is included)?

Or do I need to add extra fields to the main content region for the special cases (which will not be relevant for most pages)?

I've tried reading the docs & past posts, and see lots of references to perch_content_create, but I'm not sure how that's used or whether it would do the trick.

Thanks

Janine Dalton

Janine Dalton 0 points

  • 6 years ago
Drew McLellan

Drew McLellan 2638 points
Perch Support

Could you use page attributes to enable the extra regions, wrapping them in conditionals?

Thanks Drew - so just to confirm, the best approach is to:

1) Add extra fields for the special case content to the main content region

2) Set up page attributes for each extra special case content bit

3) Use these attributes for conditionals within the master page to determine whether to output the fields or not?

Drew McLellan

Drew McLellan 2638 points
Perch Support

I'm not sure about the best approach, as the best tends to be case-specific, and we're talking fairly generally here.

I'm imagining a solution like:

if (perch_page_attribute('use_sidebar', true)) {
    perch_content('Sidebar');
}

Great thanks for explaining