Do you have xxx attribute? I wonder!

Author Message

Jorge estévez

Wednesday 07 October 2009 10:00:30 am

Hi,

I am using a template for several classes, these classes have diferent attributes, some are the same and some not. In the code I display the values of the attributes.

Is there someway to code something like:

{if You_have_attribute XXX}
then yyy
{/if}

If I ask for an attribute not taking into consideration the class the an error appears at the debug.

The other painfull way to do this is to analize all attributes of all the clases involved wich is a very tedious way of doint it because there are houndreds of attributes to sort out and then code something like:

{if you are typeof-class Z}
	then display your attributes
{else if you are typeof-class Y}
	then display your attributes
{/if}

I am displaying al attributes values without taking into consideratio the class, so many errors arises when the debug is turned on...

thanks

Diseño Web Cuba
Web Design Cuba
www.elfosdesign.com

Gaetano Giunta

Wednesday 07 October 2009 10:32:02 am

Using $node.data_map, you get an array of all the attributes, where the array keys are the attribute names.

So using is_set($node.data_map.body) should work to test it attribute "body" is present.

If you have different attributes with the same name in different classes (eg. body is either a line of text or an xml block) you can use {attribute_view_gui} in your node template to avoid hardcoding a lot of "if" switches...

Principal Consultant International Business
Member of the Community Project Board

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 31 2025 01:17:06
Script start
Timing: Jan 31 2025 01:17:06
Module start 'layout'
Timing: Jan 31 2025 01:17:06
Module start 'content'
Timing: Jan 31 2025 01:17:07
Module end 'content'
Timing: Jan 31 2025 01:17:07
Script end

Main resources:

Total runtime0.8330 sec
Peak memory usage8,192.0000 KB
Database Queries54

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0050 588.1406151.2109
Module start 'layout' 0.00500.0040 739.3516220.7031
Module start 'content' 0.00900.8232 960.05474,432.5703
Module end 'content' 0.83210.0008 5,392.62507.8438
Script end 0.8329  5,400.4688 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00350.4154160.0002
Check MTime0.00130.1550160.0001
Mysql Total
Database connection0.00060.070710.0006
Mysqli_queries0.748089.8052540.0139
Looping result0.00050.0590520.0000
Template Total0.782593.920.3912
Template load0.00230.274020.0011
Template processing0.780293.664520.3901
Template load and register function0.00150.178810.0015
states
state_id_array0.00110.137510.0011
state_identifier_array0.00070.080220.0003
Override
Cache load0.00190.2327170.0001
Sytem overhead
Fetch class attribute can translate value0.00130.161120.0007
Fetch class attribute name0.00200.236030.0007
XML
Image XML parsing0.00070.083720.0003
class_abstraction
Instantiating content class attribute0.00000.001130.0000
General
dbfile0.00280.3322160.0002
String conversion0.00000.000940.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
2content/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
2content/datatype/view/ezxmltags/literal.tpl<No override>extension/community/design/standard/templates/content/datatype/view/ezxmltags/literal.tplEdit templateOverride template
1content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 11
 Number of unique templates used: 6

Time used to render debug report: 0.0001 secs