Chapter 7. Template Content Class

Separating presentation from business logic

—Model View Controller Pattern

In this chapter, we'll see how it's possible to customize our custom class views through the override system and the template engine.

Introduction to the content template

In the previous chapter, we saw that eZ Publish offers an out of the box template standard set. With this set of templates, it's possible to render all of the system module views correctly.

There are two template types. The first is the content template, which is used from every system module. For example, the view to see the items list of feed module. The second is the "node system template", which is used by the content module to see the object content published on the tree. This template is very important because the "content" module is the main module of the system. This module manages all of the actions on the object, such as publishing, moving, coping, deleting, and so on. It also manages the override system, through which it is possible to override the standard view for each rendered object.

We'll use the "node template" for our custom classes, and we'll also override the standard template without using custom templates.

The system provides different views for each node. By node, we mean the node of the content tree to which a content object or an instance of some class is associated.

For example, if we create a page staff below the staff node in our content tree, we can create different templates for this page (the object assigned to a node), so that it can be viewed in different ways, depending on where it will be rendered.

This feature is possible because we can explicitly tell the system which view is to be use to render a given content node.

For example, if we go to http://packtmediaproject/eng/content/view/full/74, we can see the node with ID 74 in its full view. Alternatively, if we go to http://packtmediaproject/eng/content/view/line/74, we can see the node with ID 74, but in its line view.

It's also possible to force the rendered content view of a content node through the {node_view_gui} template function, by passing a "view" parameter with the specific view string.

For example:

{node_view_gui view=full content_node=74} will render the "full" view of the node with ID 74.

and

{node_view_gui view=line content_node=74} will render the "line" view of the node with ID 74.

eZ Publish already covers some types of view, such as full and line for the standard classes, with some standard templates. But if the view does not meet the standard requirements, or if we need to create a custom view for our custom classes, we must create a rule to override these views.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
13.58.51.36