5.7 Page Types vs Templates

Permalink 5 users found helpful
Can anyone explain what the reworked relationship is between page types and templates; and specifically how one would go about setting up page controllers? Is the idea that multiple templates, all sharing a specific page type, could share the same controller or what?

focus43
 
tsdonohue5 replied on at Permalink Reply
I asked this awhile ago...don't believe I had an answer. Still don't know what the difference is really or its usage or benefit. I'm still just using page templates.
mesuva replied on at Permalink Best Answer Reply
mesuva
In 5.6 and below each Page Type would directly relate to a template file in a theme. This meant there was a 1 to 1 relationship between what a page _was_ and what a page output in terms of its layout/HTML.

Now with 5.7, Page types still represent types of page (a standard 'Page', 'News Item', 'Portfolio Item', etc), but it doesn't have a _direct_ relationship with a template. It means that you can now have a 1 to many relationship between page types and page templates.

The page type and page template itself have been decoupled.

Page attributes and composer stuff is related to a Page Type, but a Page Type now can be configured to use one or more (or all) available Page Templates a theme provides.

For an example, you can now do something like:
- Create a Page Type called 'News'
- Create three different various of a news layout, three different Page Templates (e.g. 'Standard Layout', 'Video Layout', 'Multi-column Layout')
- Configure the Page Type to allow only those three page templates to be used
- Also set different default blocks across the different page templates

Then when you create a news page, you can go to the design sidebar and change the layout to a different template _without_ changing the page type. This is really critical when you consider that things like the Page List block can do things like filter pages by page type. When you change a page type, you may find it disappears from filtered Page Lists or appears on others.

In many cases you still might end up with 1 to 1 relationships between pages types and page templates, as your different page types might need only one layout each, but now you've got to the option of one or more layouts.

Its one of those features that doesn't really seem that useful until you need it to solve a problem, then it all falls into place. With bigger sites it's really important to be able to use the 'Page Search' feature of the dashboard, to filter and manage pages by page types. Splitting the type of page from it's layout makes this much easier to manage.

I haven't done much myself with Page Type controllers in 5.7, but I would assume they would pretty much the same way as in 5.6, the controller is associated with the Page Type. The templates are really just a way to quickly change the _output_ of the page type, but I don't believe they have any controller logic behind them.
MrKDilkington replied on at Permalink Reply
MrKDilkington
I think mesuva's explanation of Page Type versus Page Template is the best one so far.

Well said, thank you.
focus43 replied on at Permalink Reply
focus43
Thats a fantastic explanation - much appreciated. On another note (and as a side question), I've figured out how to setup controller's for custom pages types. But by default, concrete5 has a "Page" page type (default.php in theme). Does anyone have any insight on how to setup a page controller for the default "Page" pagetype? that sounds confusing... let me know if further clarification is needed
malkau replied on at Permalink Reply
malkau
Thank you - that was soooo helpful.

(Curious - how did you find out how that all worked? Did someone tell you or do you just have an awesome grasp of 5.7 ? :)
mesuva replied on at Permalink Reply
mesuva
Although I have been doing a fair bit of exploration myself, I'm pretty sure it was from this video that Franz put together when 5.7 was first on the scene (plus some of the others Andrew also did along the way):

https://www.youtube.com/watch?v=vcIIM5ZgzP8...

From about a minute in, Franz briefly goes through the concepts of page templates and types. It's one of those cases where once you've got the high level picture in mind, the new features start to make a lot more sense.
tzvetan replied on at Permalink Reply
The explanation is only good for people who ALREADY know what the difference is between Page Templates and Page Types;

I see the following when I try to understand the difference between Types and Templates:

Page Templates:
http://documentation.concrete5.org/editors/dashboard/pages-and-them...

Page Types:
https://www.concrete5.org/documentation/general-topics/page-types...

Looking at these links there is NO difference!
What is Page type? HTML + PHP? HTML only?
What is Page Type? HTML + PHP again? HTML only? Are these files at all? Images? can someone give examples?
mesuva replied on at Permalink Reply
mesuva
Those two pages are both new and older documentation, which are conflicting - that's certainly going to be confusing.

You're better off comparing:
http://documentation.concrete5.org/editors/dashboard/pages-and-them...
and
http://documentation.concrete5.org/editors/dashboard/pages-and-them...

The higher level page actually gives quite a nice summary of what these things are:
http://documentation.concrete5.org/editors/dashboard/pages-and-them...

In short, Page Types are more like categories of page, it's more a data structure with individual pieces of information (attributes). They don't have a php template for them, as they're just data structures, they have no appearance by themselves.

To use the language from the doco, Page Templates are 're-usable visual formats for the various kinds of pages on your site'. These do have corresponding php files to define their code/layout.

Where the doco you linked may have confused you is that back before concrete5.7 these concepts were one and the same thing, you defined the type of the page _and_ the layout with the one thing. Now they're two separate concepts.

With that in mind, perhaps re-read my example above and hopefully it'll click!
MissMarvels replied on at Permalink Reply
MissMarvels
When using a page_template

like /page_templates/home.php
with:
<div id="industries" class="row">
  <?php  
    $a = new Area('Industries');
    $a->setAreaGridMaximumColumns(12);
    $a->display($c);
  ?>
</div>


It is impossible to ad a layout to the area. It is just not stored..

Any idea's why?
MrKDilkington replied on at Permalink Reply
MrKDilkington
@MissMarvels

I am not positive about this, but I think page templates need to go in the theme root, not in a folder.

You could try:
themes/your_theme/home.php
GBNT replied on at Permalink Reply
GBNT
I have a situation that is the opposite of the current implementation. When I saw there was a split between the Page Types and Templates I got excited but what I was excited about was actually the opposite. I'm building my first 5.7 website right now, and I must say I'm liking a lot of the new stuff as much as I'm struggling to get simple stuff done.

What I was excited about with Page Types / Templates, was the ability to have a master template that could be used by several Page Types, but with the ability to get into each defaults independently. I find much more useful the ability to have a template that can accommodate different defaults on it's regions than the opposite. I'm not saying what it's now is bad, on the contrary, I think I'll be using it too, just that if it was the opposite, I'd use it a LOT more.
Right now, if I go to the defaults of a Page Type, it sends me to the defaults of the template, which is not that useful because I could just hardcode everything needed in the template, for each Page Type on the other hand, independent defaults would be awesome.
malkau replied on at Permalink Reply
malkau
I am not sure if I understand your problem correctly... as I am sure 5.7 supports that.

I have a 5.7 site that has one master template and about 8 page types, each with their own defaults.

I've used page types for each section of my site - events, resources, membership, about, etc... these are all page types. They use a single master template for layout.

Sections differ by their header (a banner for the section, which I used as a embedded stack using defaults) and the sidebar contents. The sidebar default content changes depending on what section Page Type you create. I used defaults for the sidebar as the contents are completely editable by the page, but most pages would have the default sidebar.

Is this the kind of thing you are trying to achieve?
GBNT replied on at Permalink Reply
GBNT
Yes! That is exactly what I was asking. I guess I saw the template default with the Template name instead of the Page Type name and wrongly assumed I was going to change the template for all page types.

Thank you so much for pointing me wrong.

Cheers!
GBNT replied on at Permalink Reply
GBNT
I'm getting an issue now that I don't understand why it's happenning. It seams that Page Defaults only picks up pages created AFTER the page type has been created, and not to pages already created and assigned the page type after.
Is this a bug? What I change in the defaults don't apply to that page, but if I create a new one of that type, then it gets applied. When doing Setup on Child Pages, it doesn't even appear there. What am I missing?
malkau replied on at Permalink Reply
malkau
It should be in the "Set up on Child Pages" list. If it is missing it could be a bug.

I have not had the situation where I created the page first then the Page Type so I am unsure.

I did have weird errors with the page types when I started (I can't recall the wording) but I wasn't even able to access them - I kept getting blocked by SQL errors. I have C5 set up as a central install for multiple sites so I assumed it was an issue with this. I ended up deleting all the Page Types and existing pages so everything was "clean".

Perhaps record a short video with Jing or similar and post as a bug?
jakobfuchs replied on at Permalink Reply
jakobfuchs
It seems that is how page types work at the moment. I posted that a while back but got no response. Also if you do make changes to existing page types the pages that are already created using that specific page type don't get updated (some things do get updated others don't, would need to test it again to be for sure).