Custom Page Type - Choose template
It would be a great feature to be able to create a custom page type and choose which layout in my theme I prefer.
1. Page types use the default.php template if the page type handle doesn't match any template file name. This is usefull if you want to setup different blocks, permissions etc on the page types default content.
Dashboard -> Pages & Themes -> Page Types -> Select Default
2. The handle of the page type matches a file. ex: your theme has a template named product_details.php. A page type with the handle "product_details" would automatically use that template.
Take a look here:
I understand the handle chooses the template, however you cannot have multiple page types using the same handler.
I also understand that all I have to do to accomplish what I need is add another template in my theme. I was just wondering if anyone has thought of or implemented a way to add a page type and choose between their layouts. This would be useful for adding different default content to page types while utilizing the same layout.
I'm trying to do that and am almost there ... was about to ask if anyone knew how to setup a custom page type with custom header and footer includes.
I have an application where non-coders need to be able to add Page Types and then customize some of the content areas in those page types. The Page Types will all require 80% of the same content areas / features, but with several areas that require custom content.
My first thought is to create an attribute that indicates the template to be used and in default.php controller detect this and include my different page elements based on that attribute. This way default.php still works with everything else, but is leveraged for the page types that require it.
Separating the PageType into a template file with controller and logic and somehow getting c5 to integrate would be best I think - but I suspect some core overrides would be required?
What approach are you taking? Cheers,
I've created an attribute type (in models/attributes/types/page_template) that defines the different templates (files in theme directory) that are available for each page type.
This attribute is then added to each page type that you want to have the option of choosing between several theme files for. That's done in the Page Types -> Composer screen.
It's then pretty straightforward to use the value of this attribute in each page type's controller to work out which theme file to use when rendering the page.