ibexa

Path

ez publish / technical manual / 3.6 / templates / template basics / node templates


Caution: This documentation is for eZ Publish legacy, from version 3.x to 5.x.

Node templates

Whenever eZ publish is requested to output information about a node (either by a system URL or a virtual URL), it executes the "view" view of the "content" module. If a system URL is used, both the desired view mode and the target node must be specified in the URL. If a virtual URL is used, eZ publish will automatically know which node that should be accessed by looking up the corresponding system URL in the internal URL table. When a virtual URL is used, the system will always use the full view mode.

The templates for the different view modes must be placed inside the "/templates/node/view/" directory of a design. If the requested file is not found within the main design of the siteaccess, the system will search for it in the additional designs and the standard design. Please refer to the documentation of the automatic fallback system for more information about this feature. The "/templates/node/view" directory of the standard design contains templates for different view modes. A basic custom design typically contains a pagelayout and a full view template. The following illustration shows the locations of these templates in a custom design called "example".

Location of pagelayout and full view template in example design.

Location of pagelayout and full view template in example design.

When a node is requested (and there are no template override rules for node templates), eZ publish will generate a page that is built up of the following templates:

Pagelayout + node view full template.

Pagelayout + node view full template.

Custom node templates

A typical eZ publish site always makes use of custom node templates. The main reason for this is because there is almost always a need for displaying the various types of nodes in different ways. For example, information pages need to look different than news articles; the welcome page has to be formatted in a special way, and so on. Unlike custom system templates (which are mostly just modified copies of the standard templates placed in a custom design), custom node templates are created as override templates. The override templates are triggered by the template override system. This system offers a flexible mechanism that can be programmed to use different templates based on various conditions. For example, it can be programmed to use a template called "article.tpl" when the system is requested to show the contents of nodes referencing article objects and at the same time show "special_article.tpl" when a specific article is accessed. Please refer to the documentation of the template override system for more information about how this mechanism actually works and how it can be used to trigger override templates.

The $node variable

Whenever the system makes use of a node template (regardless of the view mode, the target node and if the template is an override or not), a variable called $node will be available in the template that is used. This variable is automatically set by the system and it contains an ezcontentobjecttreenode object that represents the requested node. This variable allows the extraction and display of various information about the node and the object that it encapsulates. Please refer to "Outputting node and object data" for information about how to display node/object data.

Balazs Halasy (04/03/2005 10:51 am)

Balazs Halasy (26/04/2005 7:46 am)


Comments

There are no comments.