Sitecore Branch Templates: Simplifying Content Creation

This is part of my back to basics series of blogs. One of the things that I have come across in different Sitecore site installs that are critical for content authors is branch templates. Branch templates have been around quite a while in Sitecore. Although Experience Editor is popular and branch templates work in Experience Editor a lot of content authors still use the Content Editor exclusively. Utilizing branch templates will make the process smoother when creating content and better guide the content authors.

So the best way to explain how branches work is to think of them as a tree. You have the trunk which would be the item you want to create, but then you have the branches that help the tree grow and help define what kind of tree it is, but most of all help feed the tree. For example a vehicle sticker. Vehicles can come with different options, different colors, etc… Each vehicle is different too and there would be options just for that vehicle and not other vehicles. Just for fun I drew a picture on my iPad to explain it visually. 🙂

Drawn on my iPad.

Branch Templates – How to Create and Use Them

Branch templates are usually created under /sitecore/templates/Branches. Right clicking on the Branches folder you will be prompted to pick a template.

After choosing a template you can add different templates underneath. In the instance below I created a branch for a vehicle sticker item. $name is the vehicle sticker template and what you see underneath is the supporting templates and template folders.

Now just set the insert options where you want the branch template and then you will get a new vehicle sticker item created with all of the supporting templates. Keep in mind all the presentation layer settings will be the same as it would be if you just inserted the vehicle sticker item.

After setting the branch template for the insert options. You will see the following after you insert the new branch template on the content tree.

Conclusion

So there you have it. The basics of a branch template. I believe this is one of the more critical features to implement when creating a Sitecore site. It will ensure content is created correctly from the start. Now that being said with newer versions of SXA, Page Branches were introduced. I will be covering that concept in the future. Regardless you can still choose to use branch templates.

#Sitecore Templates Back to Basics

We see a lot of blogs on cool things, but what I believe is missing lately are blogs on the basics of Sitecore. It has also been mentioned in the Sitecore community that we don’t have enough blog posts about the basics. So I will be doing more of these. Ironically. recently I have been holding training sessions with my colleagues at RBA. They are in roles such as QA, Strategist and Front-End development. All of them need to use Sitecore, but really don’t know the what and why Sitecore is the way it is.

I wanted to start with Templates. How I present this will be a little technical, but most of it will be broken down for easier understanding. Keep in mind this blog is geared towards the non back-end developers, but will be somewhat technical. This should give someone a basic understanding of Sitecore templates.

To explain how templates work I want to use a car as an analogy. Lets say we need to create a window sticker for a car. What fields would you need to do that?

On a window sticker you would probably see something like this.

Standard Details

  • VIN
  • Interior Color
  • Exterior Color
  • Standard Equipment
  • Options
  • Price
  • Etc…

Optional Equipment

  • Options Selected

In order to store this information we would need some sort of data structure. That is where a Sitecore template comes in to play. A template would have fields defined in order to create a window sticker item that will hold the information needed. Using this template we can create multiple window sticker items. Items btw as you can guess are created from templates. Everything you see in Sitecore is basically an item.

Template Creation

We are going to start with a simple template creation. In the Sitecore content tree the templates are usually found in the [might have a path here]/sitecore/templates folder. If you need to ever find a template for an item quickly you will see the path in the item Quick Info section. Even the Templates folder is made up of a template. See the example below.

Moving on to template creation. Typically a developer would create a new template by right clicking on one of the sections in the templates folder. For most of you reading this basic guide you don’t have to worry to much about it, but if you are curious or a new developer in the Sitecore world. This is what you will see.

We will just create a new template under User Defined. When creating a new template we will just use the default standard template. The name will be Window Sticker.

After it is created you will see several sections. For this blog on basics though we will just mainly be concerned about the Builder tab up on top. When clicking that you will see the following.

This is where we will defined the data structure for the Window Sticker item. Templates allow you to group common fields in sections. In this example we have a Standard Details section and a Options section. Each have their own fields defined. The Type of field should be determined by the most user friendly option for content entry.

Item Creation

After a template is created it usually inserted by right clicking on the item in the content tree you want to insert it under. In this case using the template created above we created a Window Sticker Item. You will see the following fields in the item. As you can see the fields we created in the template is present on the item create from the template. The Template path in the Quick Info section will take you to the template of the item if you need to make some edits.

Inheritance

One last thing to go over. One of the most powerful things about Sitecore templates is that they can inherit from other templates. So what does that mean? Well suppose you had an address section on several templates. You only need to create one address template and the other templates that need to use the same field can inherit from that template. When the item is created from the template that contains the inherited template the item will not only have the template fields, but the inherited ones too.

For instance let’s create a template called Factory Address.

The Window Sticker will inherit the Factory Address template. By default it already inherits the Standard template.

So now when you view the item created with the Window Sticker template you will see the Factory Address section.

Wrap Up

So I hope I gave you a basic understanding how Sitecore templates are created. There are many settings on them you can play around with, but for those that are non-technical I hope this gave you a basic understanding of them. Please reach out to me if you have any questions.