How to use one header for all child pages/news

Alex Pl asked on March 2, 2015 06:29

First case:

I'm using one master page for news. The parent page uses additional elements in head section. I've also edited page template -> Header and added that code in box "Add HEAD element content". I've enabled "Allow descendant templates to inherit the header" and "Inherit headers from the templates of ancestor pages". After that, this code is used in transformation news.list but isn't used in transfromation news.detail (in existed news and new information). What should I do next?

Second case:

I have hierarchical branch which contains simple text pages. Some of them have own template. I've added additional code in head section of parent page (page template -> Header -> "Add HEAD element content"). I've enabled "Allow descendant templates to inherit the header" and "Inherit headers from the templates of ancestor pages".). Is it any possibility to enable that code in pages which have own template?

Recent Answers


Brenden Kehren answered on March 2, 2015 13:57

I'd start by clearing gout all the HEAD data in each of the pages you have, this will cause problems later on when you start from scratch.

Secondly, page templates and content inheritance are your friend. Take this example: I have a blog (/Blog) that uses a single page template. The template has a repeater on it that displays all the child blog posts in a list format using the Transformation/Alternating Transformation. In the Visibility section of the repeater, the "Show for page types" property is set for "cms.blog;cms.blogpost". This will allow this repeater to show when they are on a blog page type or a blog post page type.

On the same the same page template, I add another repeater that displays all the blog posts for a month since I want my users to "filter" posts by month and the standard hierarchy for a blog in Kentico is /Blog/Blog-Month/Blog-Post. So on this repeater I set the "Show for page types" property is set for "cms.blogmonth". Now when the user clicks on a month to view the posts, the list and detail will not show and I can setup a different transformation for the list if I'd like.

You can take this same approach with adding/removing items from the HEAD section. There is a webpart that is called HEAD HTML Code. In there add the code (< link > < script >, etc) and set the show for page types properties. Or even set a macro if you'd like on the visibility. There is no reason to create multiple templates for this type of thing.

Good luck!

0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.