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.

eZ debug

Timing: Jan 18 2025 18:41:42
Script start
Timing: Jan 18 2025 18:41:42
Module start 'layout'
Timing: Jan 18 2025 18:41:42
Module start 'content'
Timing: Jan 18 2025 18:41:43
Module end 'content'
Timing: Jan 18 2025 18:41:43
Script end

Main resources:

Total runtime0.5513 sec
Peak memory usage4,096.0000 KB
Database Queries46

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0053 588.0391152.6406
Module start 'layout' 0.00530.0033 740.679739.4766
Module start 'content' 0.00870.5411 780.1563471.9922
Module end 'content' 0.54970.0015 1,252.14848.1250
Script end 0.5513  1,260.2734 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00320.5773160.0002
Check MTime0.00130.2313160.0001
Mysql Total
Database connection0.00090.167810.0009
Mysqli_queries0.513193.0651460.0112
Looping result0.00030.0586440.0000
Template Total0.519494.220.2597
Template load0.00210.374220.0010
Template processing0.517393.834420.2587
Template load and register function0.00010.017310.0001
states
state_id_array0.00070.135810.0007
state_identifier_array0.00110.191420.0005
Override
Cache load0.00170.3029130.0001
Sytem overhead
Fetch class attribute can translate value0.00060.111510.0006
Fetch class attribute name0.00060.102820.0003
XML
Image XML parsing0.00050.093110.0005
class_abstraction
Instantiating content class attribute0.00000.000920.0000
General
dbfile0.00070.1355160.0000
String conversion0.00000.001940.0000
Note: percentages do not add up to 100% because some accumulators overlap

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1node/view/full.tplfull/forum_topic.tplextension/sevenx/design/simple/override/templates/full/forum_topic.tplEdit templateOverride template
1content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
1content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
4content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
4content/datatype/view/ezxmltags/literal.tpl<No override>extension/community/design/standard/templates/content/datatype/view/ezxmltags/literal.tplEdit templateOverride template
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 12
 Number of unique templates used: 6

Time used to render debug report: 0.0001 secs