Tips and Tricks: 2. Page template reduction - Default page template

testThe second post in the page template reduction techniques series is about specifying default page templates for specific document types.

The second post in the page template reduction techniques series is about specifying default page templates for specific document types.

By default Kentico uses inheritance for displaying contents for document types like: News, Events, Blog posts and Products. In these cases, the parent page of these documents, uses a template with specific elements for displaying the documents contents:


If you take a look at the new items template, you will see that it inherits the page template from it's parent:


The way this works is that the "NewsRepeater" web part determines which transformation it should use. For the news page it will use the "NewsWithSummary" transformation and for the selected news item it will use the "NewDetail" transformation.

So what would happen if someone would add news under a different location (for example Home) not knowing that this will break the layout? In these cases it is good to use default page templates.

To make sure you use the right template, let's have a look at the page templates specific for news:


Shipping with the Corporate Site we have: "News list", "News simple list", "News with summary" and "News with summary and teasers". Basically all four templates will do the job but in this case I will stick with the page template "News with summary" that was added to the News document.

Adding a default page template is simple. Go to "Site Manager" --> "Development" --> "Document types" and edit the News document type. In the General document properties you can specify the default page template. Select "News with summary" and hit OK.


The next time someone adds a new news item notice that the page template is automatically assigned as the documents template.


If you view the news item on the live site then it will still work as expected:


Now you might be thinking how will this reduce the amount of templates in the page template selection dialogue? I will post the answer to this question in one of my upcoming, more advanced, page template reduction techniques. So stay tuned!

Next up in the series: Multiple placeholders