How to Extend Multiple Templates in Sitecore CMS

March 10, 2015

Blog | Development | How to Extend Multiple Templates in Sitecore CMS
How to Extend Multiple Templates in Sitecore CMS

This is the 22nd in a series of posts about learning how to use and develop for Sitecore CMS, and the follow-up post to “How to Extend Templates in Sitecore CMS”.

In this post I will cover how to extend multiple templates so that fields defined all parent template can be reused on a single child template. This is useful because it allows templates to built in a modular fashion.

Note:

This tutorial will expand on the templates that were updated in “How to Extend Templates in Sitecore CMS”.

Example Setup

To properly demonstrate extending multiple templates, you will need to add some new templates.

First, create a new template folder in /sitecore/Templates/User Defined named “Settings”. Within that folder create the following templates:

Note:

The format used here is:

  • Template Name
    • Section Name
      • Field Name – Type
  • Brand Settings
    • Brand Configuration
      • Logo – image field
  • Content Settings
    • Content Configuration
    • Error Page – droptree field
      • Search Page – droptree field
  • Google Analytics Settings
    • Google Analytics Configuration
      • Google Analytics ID – single line text field

The “Website Settings” template will be extended to include all of these individual templates.

Extending by Modifying an Existing Template

The way to extend multiple templates is to modify an existing template.

For this example, I’ll be modifying the “Website Settings” template so that it extends the “Brand Settings”, “Content Settings”, and “Google Analytics Settings” templates.

Select the /sitecore/Templates/User Defined/Website Settings item and view the “Content” tab in the editor.

In the “__Base template” field, expand the /Templates/User Defined/Settings/ folder and select the three settings templates within it.

Save the changes.

Examining the /sitecore/content/Example/Settings item will show the fields from the three settings templates.


Check back in next week for the next tutorial. And, as always, if you have any questions or if there’s something you’d like to see covered, drop us a line.

Tim Leverett

Senior Developer
Tags
  • Sitecore

Recent Work

Check out what else we've been working on