Written by The Jahia Team
   Estimated reading time:

What is a Content Template?

The purpose of a Content Template is to render a Content Type as a full independent webpage.

  • Content like banners, introductions, and teasers are usually used as parts of a page but rarely in their own pages by themselves.
  • Content like articles, news, and products would be appropriate candidates for a full webpage.

There can be several different Content Templates for a single component that can be used in different rendering situations.

Default Content Template

The default template for content is used when a template is not explicitly defined in the URL.

For pages, the default template is equivalent to the page selected by the content author when editing.

For other content, a default template can be assigned. This is done by selecting the "Can be used as default" option in the Studio. In the case of two content templates being applicable to the same content type, the one with higher priority is used.

Assigning a Content Template for rendering is demonstrated in the following example:

http://www.digitall.com/jahia/cms/render/defaut/en/sites/Digitall/home/newsList/news1.detail.html

Note that the content news1 will be rendered using its detail Content Template. For this example, we assumed that this Content Template exists for Content of type news.

Creating a New Content Template

Under the (second) template tab, right click the Base template and select "New Content Template".

On top of the base template fields,  the window provides different options:

  • Apply on these types: Select the Content Types on which this applies.
  • Can be use as default: Whether this is a default Content Template.
  • Priority: An integer value. In the case that multiple defaults exist for the same Content Type, the one with the highest priority will be the used.
    • This use case occurs when different modules include Content Templates for the same Types. 

content-template-create-example.png

 

Main Resource Display

A Main Resource Display is a on object within a Template that informs on which view is used to render a piece of Content. It should only be used in Content Templates.

main-resource-display-dropdown.png
 

 

Creating a Main Resource Display

The edit window provides a field for selecting which views are used to display the main resource. When none are selected, the default view is used.

main-resource-display-edit-window.png

Example: Digitall Event Content Template

Below is an example of a completed Content Template for a piece of Content of type Event. Note the main resource displays being used and the views that were selected for each of them.

content-template-event-example.png

 

Exercise: Create a Content Template

  1. Create a detail view for Employee.
    • This detail view displays all Employee Properties.
  2. Create a Content Template in the Studio for Employee. It will display:
    • The detail view for Employee
    • A back button
  3. Modify the default view of Employee to include the Employee name as a link to the Detail View rendered using the Content Template.