ez.no / ezpublish / documentation / customization / custom design / node_view_gui
These documentation pages are no longer maintained. Please visit the new documentation site.
Different classes have different attributes. If you wish to make a list containing some attributes from all objects and the objects are of different classes, you might have a problem.
Example:
{let articleList=fetch( 'content', 'list', hash( 'parent_node_id', $node.node_id, 'sort_by', $node.sort_array ) )} {section name=articleLoop loop=$articleList} <H2>{$articleLoop:item.data_map.title.content}</H2> {$articleLoop:item.data_map.intro.content.output.output_text} {/section} {/let}
This example will work fine if all objects in $articleList have the attributes title and content. But if the content of the array is different types of classes with different attributes, we have a problem. The solution to this problem is the function node_view_gui and override templates.
node_view_gui let us place the code for viewing the article in a separate file. Here is a simple example:
{let articleList=fetch( 'content', 'list', hash( 'parent_node_id', $node.node_id, 'sort_by', $node.sort_array ) )} {section name=articleLoop loop=$articleList} {node_view_gui view=element content_node=$articleLoop:item} {/section} {/let}
For each element in $articleList we will include the file element.tpl and this file will have the current node in the loop defined as $node. element.tpl is placed in templates/node/view/.
element.tpl:
<H2>{$node.data_map.title.content}</H2> {$node.data_map.intro.content.output.output_text}
These two files will do the same thing as the first example in the section. However, this does not solve our problem direcly. We can now create override templates for the element and then get a different view in the list based on the class.
override.ini:
[element_class_2] Source=node/view/element.tpl MatchFile=element_class_2.tpl Subdir=templates Match[class]=2 [element_class_3] Source=node/view/element.tpl MatchFile=element_class_3.tpl Subdir=templates Match[class]=3
element_class_2.tpl:
<H2>{$node.data_map.title.content}</H2> {$node.data_map.intro.content.output.output_text}
element_class_3.tpl:
<H2>{$node.data_map.title.content}</H2> {$node.data_map.text.content}
If we place these files in our override directory these files will be used for the specified classes. The ID's and attributes defined in the override templates have to be set based on the existing class setup on your site.
For more kernel functions, check the documentation here
Comments
Fixed dead link
Ole Morten Halvorsen
Tuesday 24 February 2004 4:41:44 pm
We have made some major updates to the documentation lately, so there are unfortunately some broken links.
Dead Link not fixed
John Mina
Tuesday 24 February 2004 3:28:10 pm
the link is still dead as "Iris Hoekstra " mentioned before me
adn some other links are having the same problem as well
Dead link
Iris Hoekstra - Roscam Abbing
Thursday 12 February 2004 12:26:24 pm
The http://ez.no/sdk/eztemplate/view/function_list/ link at the bottom of the page doesn't work. Regards, Iris