Custom Page Type - Choose template

Permalink
Is there a way to choose the parser that is used when creating a custom page type? I believe right now it just parses default.

It would be a great feature to be able to create a custom page type and choose which layout in my theme I prefer.

Regards,
Kyle

 
ryan replied on at Permalink Reply
ryan
Page types can be used two different ways:
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:
http://www.concrete5.org/documentation/developers/pages/themes...
iconicschema replied on at Permalink Reply
Thanks for your quick reply,

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.
MrNiceGaius replied on at Permalink Reply
MrNiceGaius
Are you talking about including a custom header.php & footer.php file for the custom page type?

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.
MrNiceGaius replied on at Permalink Reply
MrNiceGaius
oops ... just saw this is a two year old thread :)
snowbound replied on at Permalink Reply
snowbound
MrNG - I am interested in this as well. I haven't done tonnes of research yet, other items on the list, just prepping for the dev. So there may yet be answers in the forums.

THE CASE:
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,

Gerr
codecloud replied on at Permalink Reply
codecloud
I've just finishing off writing a custom attribute type for exactly this purpose.

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.