Tip: Customize attriubute views for relations

Author Message

Gerhard Sletten

Wednesday 19 November 2008 2:23:16 am

If you are using relations in your models, you might want to customize them so you can pick with view from your node override templates.

<b>content/datatype/view/ezobjectrelation.tpl</b>

{*?template charset=utf-8?*}
{if is_set($class) }
	{def $view_class = $class}
{else}
	{def $view_class = "text_linked"}
{/if}
{if is_set($size)|not() }
	{def $size = "tiny"}
{/if}

{if $attribute.content}
	{node_view_gui view=$view_class size=$size content_node=$attribute.content.current.temp_main_node}
{else}
   {'No relation'|i18n( 'design/standard/content/datatype' )}
{/if}
{undef}

<b>Usage from node template:</b>

{node_view_gui view=line size=productimage_horizontal content_node=$node}

<b>content/datatype/view/ezobjectrelations.tpl</b>

{*?template charset=utf-8?*}
{if is_set($class)|not() }
	{def $class = "text_linked"}
{/if}

{if is_set($size)|not() }
	{def $size = "tiny"}
{/if}
{if $attribute.content.relation_list}
{if is_set($render_as_list) }<ul class="relationlist">{/if}
	{foreach $attribute.content.relation_list as $Relations}
		{if $Relations.in_trash|not()}
			{if is_set($render_as_list) }<li>{/if}
    		{node_view_gui view=$class size=$size content_node=fetch( content, node, hash( node_id, $Relations.node_id ) )}
			{if is_set($render_as_list) }<li>{/if}
		{/if}
	{/foreach}
{if is_set($render_as_list) }</ul>{/if}
{else}
	{'There are no related objects.'|i18n( 'design/standard/content/datatype' )}
{/if}
{undef}

<b>Usage from node template:</b>

{attribute_view_gui attribute=$node.object.data_map.features class=image size=icon render_as_list=true}

Triathlon, Webdev, Novels and Cooking..
http://www.gersh.no

Powered by eZ Publish™ CMS Open Source Web Content Management. Copyright © 1999-2014 eZ Systems AS (except where otherwise noted). All rights reserved.