ORGANIZING TEMPLATES FOR REUSE

Chapter 4 focuses on the creation and management of the templates themselves. This section discusses the practical application of those templates and how managing templates correctly can make for a very flexible presentation engine.

In most cases a document type has a one-to-one relationship with a template. By default, this is the case when you create a document type and elect to have a template created as part of the process. What you may not know is that any given document type can have any number of associated templates, as shown in Figure 8-4.

FIGURE 8-4

image

Several reasons exist for this feature:

  • A document type may support different types of output based on media type or device type.
  • A node's content may need to have the flexibility to be presented differently without having to recreate the content using a different document type.
  • Features of a page may need to be toggled by an editor, such as the inclusion of second-level navigation, a sidebar, or other content.
  • A multi-site environment, as in Chapter 6, needs to have different templates based on the site that is being rendered.

So, when you create your templates, make sure to take into account the various page types that they need to support. One example of when to share a document type with two templates is for toggling a feature of a page. To illustrate the point, follow these steps:

  1. Log ...

Get Umbraco User's Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.