ez.no / exponential / documentation / customization / custom design / examples / common template issues
Here you will find examples of some features you are likely to need when developing your own templates. Consult the eZ template documentation for the complete documentation of the template engine.
In this example we will create an override template for the 'full' view mode of the Folder class. To test it, create a file called 'full_class_1.tpl' in the directory 'design/admin/override/templates/node/view'. Login to the admin interface, create a test folder, and fill it with some articles.
Note: When developing templates you should disable the view cache. When this is enabled, the template engine does not check the modification date of the templates, thus you will not see any changes. Edit settings/site.ini and set ViewCaching=disabled in [ContentSettings].
This example simply lists out the names of the articles who are children of the folder we are viewing. The fetch statement fetches a list of children whose parent node id equals our node id, and assigns it to the template variable $children. The name of our node is printed as a header, and then we use a loop to print the name of each child. Looping is done with the section function. Note how we assign a namespace for the loop, called 'Child' in this example.
{* set children variable *} {let children=fetch('content',list,hash(parent_node_id,$node.node_id))} <h1>{$node.name}</h1> {* loop children and print name *} {section name=Child loop=$children} {$Child:item.name}<br> {/section} {/let}
This will output something like this:
TODO: add screenshot
Log in or create a user account to comment.
Comments