6

We are 80% from the completion of the project. And noticed that we need to create a couple of renderings that must exist on all pages.

I thought the best place to do this would be presentation detail of base template standard values. However, it appears that when you add rendering you need to also choose layout as well.

Questions:

  1. Are Sitecore templates designed to inherit the presentation details of base templates?

  2. If above is yes, how do we handle a scenario where inherited templates can have different layouts?

  3. If no, what's the best way to solve this issue?

I've faced this issue a couple of times, where I ended up adding the rendering to all the page templates one by one :-).

Any best practices appreciate.

7

If you have not already used a base template with presentation, this will be tricky. Normally I would have a base page template with some core presentation elements and then all other page templates would inherit from that - also I try to have very few page templates.

For your problem you are probably going to have to add the element to the standard values on your page templates.

You could script this with Sitecore PowerShell Extensions using something similar to this:

$item = get-item master:\content\Demo\Int\Home
$device =Get-Device -Default
$contentDataSource = get-item master:\content\Demo\Int\Home\about-us\employee-stories\adam-najmanowicz
$ImageDataSource = get-item master:\content\Demo\Int\Data\Images\d56cf7e777a2496aa6489a7bffc03539

$rendering = get-item master:\layout\Sublayouts\ZenGarden\Basic\Content
Add-Rendering -Item $item -Device $device -Rendering $rendering -Placeholder main -Parameter @{FieldName ="Title"} -DataSource $contentDataSource
$rendering = get-item master:\layout\Sublayouts\ZenGarden\Basic\Image
Add-Rendering -Item $item -Device $device -Rendering $rendering -Placeholder main -DataSource $ImageDataSource
$rendering = get-item master:\layout\Sublayouts\ZenGarden\Basic\Subtitle
Add-Rendering -Item $item -Device $device -Rendering $rendering -Placeholder main -DataSource $contentDataSource
$rendering = get-item master:\layout\Sublayouts\ZenGarden\Basic\Title
Add-Rendering -Item $item -Device $device -Rendering $rendering -Placeholder main

Source: Adam Najmanowicz Gist.

This should serve as a good starting point. Here is the documentation of the Add-Rendering function:

https://sitecorepowershell.gitbooks.io/sitecore-powershell-extensions/content/appendix/commands/Add-Rendering.html

Credit to @pascal-mathys for this answer on this question

  • yes we have base template. Looks like 8.1 initial release have this issue kb.sitecore.net/articles/649914. I applied the fix but when I reset it wipes out it's layout/renderings and only shows the base template one. Any idea? – Nil Pun Sep 22 '16 at 2:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.