node_view_gui

These documentation pages are no longer maintained. Please visit the new documentation site.

Object lists

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.

Other kernel functions

For more kernel functions, check the documentation here

Comments

Fixed dead link

Thank you for pointing this out.
We have made some major updates to the documentation lately, so there are unfortunately some broken links.

Dead Link not fixed

Pitty that no one is having a look and replying our requests regarding any problems we face i nthis web site or any problems we face understadning the Ez System
the link is still dead as "Iris Hoekstra " mentioned before me
adn some other links are having the same problem as well

Dead link

Hello there,

The http://ez.no/sdk/eztemplate/view/function_list/ link at the bottom of the page doesn't work. Regards, Iris

Contents

Customization

Access control
eZ publish API Documentation
Content structure
Custom design
    User specified parameters
    Template variables set by ezPublish
    Introduction
    Variables, arrays and objects
    Node
    Database connectivity
    Sections
    File placement
    Override templates
    node_view_gui
    Pagination
    Caching
    Stylesheets
    Pagelayout
    Printable pages
    Examples
Components
Tips & Tricks
Troubleshooting


Created

04/07/2003
11:30:18 am
by Bård Farstad

Last updated

24/02/2004
4:38:00 pm
by Ole Morten Halvorsen

Authors

Bård Farstad
Ole Morten Halvorsen



This page is part of the eZ Publish documentation. The documentation is available under the GNU Free Documentation License. All contributions will be released under the terms of this license.