Forum
Modular layout
Hi
I want to be able to add perch content in a modular way to a page.
For instance if I were to do it programmatically:
<?php perch_content('Section 1'); ?>
<?php perch_content('Section 2'); ?>
<?php perch_content('Section 3'); ?>
<?php perch_content('Section 4'); ?>
Section 1 may be a 2 column layout with an image and text Section 2 could be full width text Section 3 possibly 4 images
Now I can achieve that by doing the above and then selecting templates as I go, no problem. But what if I want the content editor to add extra sections, then deciding on template? Can this be done without actually referencing them in the master page? Allowing multiple items doesn't allow a change in template selection does it?
Perhaps I would add section 5, 6, 7 and choose a template for each one.... thus creating a modular layout, which would then be able to be re-ordered. Do you get what I mean here? Is perch's simple approach not geared for this approach?
Thanks
Adam
I've just seen that you can change the template once in the mode of adding multiple regions. So I guess that answers my question then.
Ah, take that back. That template change applies to all regions in a multiple region list.
The template is for the region, not the item.
Sure, I now see that, so if I have 6 items they all have to have the same template. I guess there is no way for me to add regions in the back end if they are not in the Master Page.
No, but the master page could dynamically provision regions.
How do you mean dynamically provision them please can you expand. I am familiar with master pages and see nothing about dynamically adding them in the docs.
Thanks!
There's nothing in the docs - this isn't Perch functionality.
You can use
perch_content_create()
to create regions, and you can write code to dynamically callperch_content()
orperch_content_custom()
so it would be theoretically possible to create a system to do that as needed.https://docs.grabaperch.com/docs/developers/creating-regions/
Yeah sure I understand that, it's something I use all the time with Master pages thanks.
It's the concept of adding regions from the back end dynamically that I seem to be realising isn't possible, nor part of the perch 'ethos of simplicity' - something that I like and enjoy coming back to after working with other CMS's.