Prev Next |
Especially for developers familiar with other CMS architectures, it is critical to understand that in Sitecore a Template is simply a data structure that can be presented with any number of Layouts, Sublayouts and Renderings – a Template is not necessarily tied to a single presentation format.
In object-oriented programming terms a Sitecore Template is most like a class defining a number of Fields (Properties). In relational database terms Templates function most like tables. Templates can be created programmatically but more frequently are created through the Sitecore UI. Common Template types include a generic Page, JobPosting and NewsArticle. Different Template types are commonly associated with different Layouts, Sublayouts and/or Renderings, and are also used for branching, presentation and other rendering logic. Using the same Field names in multiple Templates can aid in reusing rendering logic if those fields have the same basic function, especially Title and Text.
When designing Templates, focus on data structure and types instead of how data will be presented on the web, though obviously content relations are important. Simplify Templating requirements when possible by reusing Templates. For instance, if most pages on the site are built with a generic Page Template, and the site map does not have any or many special characteristics, a SiteMap Template may not be needed – control data for the site map (how deep it should crawl, etc.) can be stored in the home page, which generally has a dedicated Template. When defining Template requirements, try to keep the number of Templates low to reduce maintenance.
Most Templates should have at least one Master; if new Items based on the same Template behave differently in different sections of the site, such as automatically creating different children, allowing different types of children to be created, or applying security differently, additional Masters can be implemented.
If layout settings are not specified on an individual Item, they will be inherited from the Item’s Template. A Template may therefore be duplicated to control rendering logic by Template type, associating different Layouts, Sublayouts and/or Renderings with Items associated with the copy.
The structure (Fields) of a Template control the structure (Fields) which appear on the Masters and Items associated with that Template. As soon as a Field is added to a Template, that Field appears on all Items and Masters associated with that Template.
Prev Next