Page Types and Page Templates

Permalink 1 user found helpful
When installing a theme what we use to call Page Types are now added as Page Themes but there is an option in the sidebar to display Page Types, I just have one showing called Pages and all my theme "page Types" are now under Page Themes.

What's the differnece between Page Types and Page Themes?

pvernaglia
 
andrew replied on at Permalink Best Answer Reply
andrew
In the past, we just had page types. They mapped to template files in the theme's directory, with any template file that didn't exist routing to default.php. So you might get a mixture of these in your theme:

"left sidebar"
"blog entry"
"detail page"
"home page"
"right sidebar"
"full width"

as your page types. Unfortunately, that's not super flexible. What if I want to use some of the programmatic features of page types (e.g. "filter by 'blog entry'") but I want that blog entry to have a right sidebar? So in 5.7. we have split them in half. Page types have no presentation code to them. (They can optionally have a controller that runs in the background when they're rendered but that's another post.) They are simply a list of data in the dashboard that tells how they can be worked with (e.g. do they open in composer or go straight to the page. What blocks and attributes get attached to them by default? How do those defaults work? What page templates can work with them?) Page templates, by contrast, are what page types used to be. They map one to one with a file in the theme. So now, in 5.7 you have something like the following:

Page type: Empty page. Templates available - all.
Page type: Blog Entry. Templates available - left sidebar, right sidebar
Page type: Portfolio Page. Templates available - only left sidebar.

Each of these different types has dramatically different default content on it, and different composer interfaces. You can also get the pre-5.7. behavior back by simply creating a page type and a template of the same name, and setting up that page type to only use that template.

Hope this helps. We're really excited about this. For years we struggled explaining page types because half the time we talked about presentation and half the time we talked about them as an "object model" for different types of data. Now we don't have to make that distinction.
tsdonohue5 replied on at Permalink Reply
I still don't understand...anyone have some other examples or docs for this.

Thanks
Veronikan replied on at Permalink Reply
Veronikan
Since this topic has some attention here, I thought I'd ask. I've looked over the docs and have done forum searches but I cannot find page template analog for this code:

$c->getCollectionTypeHandle()


If page templates create the presentation layer, I need to be able to get the page template handle so I can apply it as a class to the body in order to do template specific styles.

How do I get page template handle in 5.7?

Thanks.
andrew replied on at Permalink Reply
andrew
Looking in the core I see $c->getPageTemplateHandle() – but we may have added that recently. If that method doesn't exist, try this:

$pt = $c->getPageTemplateObject();
if (is_object($pt)) {
    $handle = $pt->getPageTemplateHandle();
}
Veronikan replied on at Permalink Reply
Veronikan
The former didn't work. With the latter I get:

Call to undefined method Concrete\Core\Page\Page::getPageTemplateObject()
Veronikan replied on at Permalink Reply
Veronikan
I got it to print out the template id, and that may work for now.

<?php echo $c->getPageTemplateID() ?>
pvernaglia replied on at Permalink Reply
pvernaglia
try this

PageTemplate::getByID($c->getPageTemplateID())->getPageTemplateHandle()
andrew replied on at Permalink Reply
andrew
Yes – my fault. We may have added both those convenience methods recently and only have getPageTypeID() up until now. This code will probably do what you want.
Pluto replied on at Permalink Reply
Pluto
This is helpful for me.
Thanks @pluto