ez.no / ezpublish / documentation / customization / custom design / node
These documentation pages are no longer maintained. Please visit the new documentation site.
All pages we wish to see are a representation of one node. It could either be to view the object or a list of all nodes with this node as a parent. An object called $node will always be set by eZ publish and represent the current node.
We can directly fetch several values from the $node object. This is some of them:
|
Attribute |
Description |
|---|---|
|
node_id |
ID of the node |
|
name |
The name of the object |
|
path_array |
An array containing full path to the object |
|
sort_array |
An array describing how sub-nodes should be sorted |
|
data_map |
An array containing all content attributes for the object |
We can easily print out the name of the current object like this:
<html> <body> <h1>{$node.name}</h1> </body> </html>
The name will then be displayed as it is decided in Object name pattern in the class of the object.
The data map is an array that contains all content attributes for this object. The names of the keys of this array are the same name as the identifiers of the attribute when we created the class.
All values in the data map are stored as objects. These objects have an attribute called content. The result we get after requesting the content attribute is different based on what kind of datatype this is. The simple datatypes like Text line, Text area and so on returns the text directly, but the more advanced datatypes like XML Text field and Image returns objects or arrays of objects. This is because we often want to do more than just returning the input from the author. With an XML Text field we would for example like to convert the XML input to normal HTML. For detailed information about all possibilities check the documentation for the datatype.
Here are some of the datatypes:
|
Datatype |
Output code |
Comment |
|---|---|---|
|
Text line |
.content |
|
|
Text area |
.content |
|
|
XML Text field |
.content.output.output_text |
Converts XML to HTML |
|
URL |
.content |
|
|
Binary file |
.content.original_filename .content.filesize |
|
|
Image |
.content[small].full_path |
Content is an array, keys are size on the image (small, medium, large or reference). Returns path to the image on the server (place inside an IMG tag) |
If we would like our template to show an article containing a title (Text line), intro (XML Text field) and body (XML Text field) the code would be like this:
<h1>{$node.data_map.title.content}</h1> {$node.data_map.intro.content.output.output_text}<br /> {$node.data_map.body.content.output.output_text}
You can of course add as much HTML code in between as you would like to make the design as you like.
If we would like a template to show an Integer and an Enum (value and element) the code could be like this:
<h1>{$node.data_map.myinteger}</h1> {$node.data_map.myenumvalue.content.enumobject_list.0.enumvalue}<br/> {$node.data_map.myenumvalue.data_text}<br />
You can find more examples in the directory /design/standard/templates/content/datatype/view. There is one template file for each datatype. Set Debug=enabled in the Templatesettings section of site.ini.append to see where and when these files are used.
Comments
{$node.data_map.myenumvalue.data_text} does not work
esu vytis
Friday 19 August 2005 1:08:17 pm
Is .content.output.output_text necassary or not?
James Ward
Monday 18 August 2003 5:04:56 am
{attribute_view_gui attribute=$content_version.data_map.intro}
Seems to work fine for displaying XML Text fields. Is the additional code really necessary?