0

Since we have our Templates => __Standard Values => Presentation => Detail => Layout Details pointing to Visual Studio MVC /Views/Shared/_Layout.cshtml, and this Layout already defines the Placeholders:

<body class="...">  
@Html.Sitecore().Placeholder("header")  
@Html.Sitecore().Placeholder("menu")  

        <main class="main-content">  
            @Html.Sitecore().Placeholder("hero")  
            @Html.Sitecore().Placeholder("breadcrumb")  
            @Html.Sitecore().Placeholder("main")  
            @Html.Sitecore().Placeholder("footer")  

I'm wondering why it is defined again, in the "Controls" of the "Layout Details" => "Device Editor" => Default => Shared and Final:

(Control or Rendering) (Placeholder)
Header header
Menu menu
Default Hero hero
Breadcrumb breadcrumb
Footer footer

How does that play together, with the placeholder keys specified in the layout /View/layout.cshtml. Does it take precedence, override, etc.?

It is true that in the case of the Presentation Details, its' referencing the Placeholders indirectly, thru the Control/Rendering. But still, that makes 2 lists of Placeholders.. which wins?

I'll create some test scenarios, but if someone has insights they'll be more than welcome!

We have 8.1 so perhaps these somewhat overlap with the "ways to do it" vs the ways to do with legacy of former menus co-existing with latest ways?

7
  • when you say "defined again" do you mean on the item that was created based on the template with the aforementioned standard values?
    – Marco
    Jan 11, 2018 at 21:37
  • I mean the Template => __Standard Values => Presentation => Details => Layout Details => Default device so not yet the content items based on the Template. And I know the content items can themselves override the Template => __Standard Values => Presentation Detail. Jan 11, 2018 at 21:41
  • @CoeurDusite If you define something in the __Standard Values for a template that items will later derive from, than whatever presentation details you've defined on the __Standard Values will be used in that derives item. Jan 11, 2018 at 22:18
  • I just launched a video this week that specifically talks about how Presentation details work: youtube.com/watch?v=UviNUv4mMPQ Maybe that'll be helpful here. Jan 11, 2018 at 22:21
  • 1
    Can you provide a screenshot, might more easily explain what you are seeing.
    – jammykam
    Jan 11, 2018 at 23:15

1 Answer 1

1

I've re-read this questions a couple of times and I think there is some general confusion that you have with how Placeholder keys work in Sitecore. So like you mentioned, you have a Layout view defined. That should be the case that you would always have for any page you want to have UI interface. Example, if you are building a blog article page, you would at the bare minimum need to create a new layout in the layouts folder and assign that to either the item directly or the items template standard values:

Define a Layout

That layout can have html within that file, which you specify via it's path, which you can see within the screenshot. That html can also contain Sitecore html helpers which is how you would define a Placeholder key. These are definitions that allow you to add controls (typically called renderings in Sitecore) to a page, which is done via presentation details.

So keep in mind, the intent for a layout is to build the basic shell of your pages on your site and most times it will contain html related to being just the shell, such as html head and a pretty simple body tag. It's the placeholder key definitions, that allows you to setup a blog page vs a forum page using the exact same layout in Sitecore.

So for the blog page it would have the same layout defined, but different renderings defined vs. the forum page in it's default devices presentation details. When you assign additional controls/renderings to a page (either directly to an item or via it's standard values) you are telling it which controls should show up for that specific placeholder key.

An example from your layout above:

You have a Layout, that's been assigned to an article page for example. When you are viewing the presentation details for this article page, you should see that the Layout is selected which will map to the html you have copied above. The controls tab should show renderings (which are separate groupings of logic, which can related more to a partial view in .net MVC). For example, there is a header rendering, and it's placeholder is set to "header" in the presentation details. So the header rendering is being added to the page in place of the placeholder key header from your layout file. So when you view the page on the front end, you will no longer see @Html.Sitecore().Placeholder("header"), but instead you will see the rendered html from your header control/rendering.

So the answer to your question is this, if you don't specific a rendering to use a placeholder key, then nothing will show up there on the front end. Example, if you hadn't specified a header rendering to use the header placeholder key, than nothing would display there. And when you do specify a rendering to display when you specify it's key, it will replace that placeholder with the rendered contents of the renderings you've selected to display in that placeholder key placement.

Also this is how it's always worked, and you should find this same behavior in 6, 7, 8 and even 9.

2
  • Thank you Dylan for this detailed Layout principles explanation! This solidifies my understanding. I will experiment some more, I think I was thinking of the Presentation Detail "Controls" as listing the Placeholders, instead of the Renderings they really do, because of the same names we gave both. Thanks again! Jan 12, 2018 at 19:58
  • Absolutely, let me know if there is anything else you need help with. You can find me either on Twitter or Slack. Jan 12, 2018 at 20:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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