Forum

Thread tagged as: Question, Suggestions

Solution or Suggestion for Shared Regions

Not sure if this is currently possible, if not maybe something for the future?

Lets say I have several pages created using a Pages template using a region called "Promo Banner" that has a template assigned to it.

It would be great if there was a way to create several versions of this as shared regions and assign them to specific pages.

Now I could do this by naming the region differently in the template say Promo Banner 1, Promo Banner 2 etc and then it would put the appropriate shared region there. But as these are pages from the Pages templates I would need to create a separate template for each page type, a little less dynamic.

I used Opencart recently and it has a layouts feature which links to modules so you can assign an instance of a module to several layouts.

It would be handy to have Perch enable you to choose to add a shared region within a page within the admin page rather than having to add it to a template, especially where pages share the same template.

Ideal for reusing different versions of banners or like?

Nigel Coath

Nigel Coath 1 points

  • 7 years ago
Drew McLellan

Drew McLellan 2638 points
Perch Support

You can do that by populating either the region key, page option or template option in you page using content from another egion on the page.

Could you point me to info on these methods? I cannot find a way todo this.

Also is there or could there be developed a way to turn off a region in admin. While you can delete a region that is permanent. Say you wanted to run a promo, or decided to turn off some content, how could you do this?

Drew McLellan

Drew McLellan 2638 points
Perch Support

It's a bit old, but see the section "Turn things on and off with conditional tags" in this blog post:

https://allinthehead.com/retro/342/five-interesting-ways-to-publish-with-perch

Okay thanks thats excellent, been looking for a way to do that for some time.

Where can I find info on populating either the region key, page option or template option in you page using content from another egion on the page? Is this in the same article as was not sure?

Drew McLellan

Drew McLellan 2638 points
Perch Support

perch_content_custom(perch_content('Region name', true), array(...));
perch_content_custom('My region', array(
    template => perch_content('Template', true),
));

If I wanted to insert this within admin how would I do this? As the pages using this region are created via Perch using a master template I cannot add this code.

Could I use your method for turning things off for this too?

Drew McLellan

Drew McLellan 2638 points
Perch Support

Yes, that's right.

So where would I place the above code wrapped in the conditionals, in the content template or the master page template?

Am just a bit stumped.

I need to end up with a way to select which shared region to use on a page by switching the region name I think.

I am also unsure how you would create the shared regions as you would surely need a page with them on to make them show up in Perch?

Drew McLellan

Drew McLellan 2638 points
Perch Support

Template code like <perch:if> etc goes in the templates.

If you're testing with PHP, that would go in the master page.

Okay will try that. Is it also possible to switch whole pages off created via Pages? I have a client that I am developing a website for each of their dental practices, some offer services others currently do not.

In that site, I would want to keep that content page in case they do later on, can I add an enabled drop down at master page level?

I have tried various things and just cannot see how I can make this work.

To confirm:

  1. A method to enable switching a region name so that one could switch different content versions of the same template e.g. a banner that has different content but uses the same template. In a page that has been created by Perch via pages.

  2. A method to enable or disable a whole page that has been created by Perch via pages.

Are these possible?

Drew McLellan

Drew McLellan 2638 points
Perch Support

What do you mean by disable a page?

Okay so say you have a page, but you wish to switch it off so it no longer displays on the site. The page was created as a pages app page.

I suppose you could hide it from navigation, but it will still show up if it got indexed before being disabled. Ideally a simple way to enable/disable a page much like your solution to enable/disable a region.

With regard to the first point, I have used Opencart and they have modules of content that appear in various layout positions. Once a piece of content is created in a module, you can assign a layout (which a page or range of pages use) this determines where it appears. You can also enable/disable it without deleting it.

Now say we have a shared region called Content A and another Content B, if there was a way to change the name of a region in a page within admin then it would apply a different shared region?

Drew McLellan

Drew McLellan 2638 points
Perch Support

What would happen when someone visits the disabled page?

True. If I want to keep a page but disable it currently before the site goes live can I hide from navigation and prevent it indexing?

What about the other issue regarding switching regions within admin above?

Drew McLellan

Drew McLellan 2638 points
Perch Support

$show = perch_content('Show region A', true);

if ($show) {
    perch_content('Region A');
}else{
    perch_content('Region B');
}

Sorry I am sure this is simple but it means little to me! Is this code to be placed in the master page template and how would it be controlled? Thanks for trying to help but I am struggling with this!

Drew McLellan

Drew McLellan 2638 points
Perch Support

I don't know how to help more.