Can multiple page types use the same base php file?
Permalink
Here's what I'd like to do:
Use one generic page type template.
Pre-populate that template with a variety of blocks by default (I already know how to do that in the dashboard).
End up with several page types that the user can select from that each have a different configuration of default blocks, but use the same page_type.php file.
Possible?
It seems silly to have page_type1.php, page_type2.php, etc that are exact duplicates just so I can have different sets of default blocks.
Thanks for your help!
Use one generic page type template.
Pre-populate that template with a variety of blocks by default (I already know how to do that in the dashboard).
End up with several page types that the user can select from that each have a different configuration of default blocks, but use the same page_type.php file.
Possible?
It seems silly to have page_type1.php, page_type2.php, etc that are exact duplicates just so I can have different sets of default blocks.
Thanks for your help!
D'oh!
I realized that, for my purposes, I can use default.php as my generic template.
Then I can create new page templates that don't have php files associated with their handles (eg "page_type" -> "page_type.php").
Each page type (with a unique handle) will use the default.php template (because there is no php template with that handle name) and I can assign whatever default blocks I want.
At least in theory :-)
I realized that, for my purposes, I can use default.php as my generic template.
Then I can create new page templates that don't have php files associated with their handles (eg "page_type" -> "page_type.php").
Each page type (with a unique handle) will use the default.php template (because there is no php template with that handle name) and I can assign whatever default blocks I want.
At least in theory :-)
Actually i re-read that again, and you can do the whole implied page types or simply do something like a switch statement on areas based on the collection type handle in the same php file. This gets a little more complex but getting a collectiontype (or page_type if you must) isn't too bad from code.
But pageTypes are called by unique handles. if you try to double up on one handle, you are going to explode things.
C