Search code examples
sitecoresitecore8sitecore7.2

Where to set sitecore layout and sub-layout


I am a newbie to sitecore and wanted to ask a question about layout inheritance. I am using web forms and do all my work using Sitecore Rocks. I have a base template that has three fields. I also have 2 other templates (Hardware and Product) that inherit from the base template. I have created a Hardware content item and under it is a Product content item.

I created my layout, sub-layout, and their respective definition item. In my layout I have a placeholder control so I can dynamically bind a component to it.

Now, I went ahead set the layout and sub-layout to the standard values of the base template. Now, by me doing this, will both the Hardware and Product items inherit the layout and sub-layout? I think the answer is yes because when I preview both items, they render per the layout and sub-layout I defined. Is this a standard practice? Also, if I define a different sub-layout for the Product item and set it to the standard values of the Product template, how come I get "...layout not found" error message when the layout is defined on its base template?

If someone could shed a light on this for me, I would appreciate it. I really want to get this concept down as I realize that it's the building block to Sitecore development.


Solution

  • The answer to your first question is YES, if you create a base template with some __StandardValues and you inherit the Product and Hardware templates from the base template, without defining their own standard values, any content items created from these templates will inherit the presentation details from the base template.

    To answer your second question, you get a Layout not found, probably because you haven't defined a layout on the __StandardValues of the Product template, as you expect to be inherited from Base. But it does not work this way.

    Let me explain:


    In my screenshot below, you can see the three templates you mentioned. Note that:

    enter image description here

    • BaseTemplate has __StandardValues
    • ProductTemplate inherits from Base but has no __StandardValues

      Any content items created from this template will inherit form the StandardValues of the Base template, as no custom values exist

    • HardwareTemplate inherits from Base but has it's own _StandardValues

      Any content items created from this template will not inherit from Base, it will use its own settings from _StandardValues

    As soon as you change the Presentation Details of an item, your item will keep your changes.

    A very detailed explanation on how Standard Values work can be found here: http://www.sitecore.net/learn/blogs/technical-blogs/john-west-sitecore-blog/posts/2013/01/all-about-standard-values-in-the-sitecore-aspnet-cms.aspx