Determine attributes in a class

Author Message

Lars Eirik R

Monday 22 March 2010 7:48:30 am

What is the best way to check if a class contains an attribute when iterating through an array of objects in a tpl?

I have tried to do something like this {if $node.data_map.mytest}

The problem is that i get errors whenever my node does not currenctly contain a mytest attribute.

Please help.

Norbert Wagner

Tuesday 23 March 2010 3:53:05 am

Hi Lars,
did you try

{if is_set($node.data_map.mytest}

Lars Eirik R

Tuesday 23 March 2010 4:46:53 am

Hm. thanks for helping.

I tried it now, but still get the same problem.. it reports errors if mytest does not exist

Nicolas Pastorino

Wednesday 24 March 2010 4:02:13 am

Another option :

{if is_unset( $node.data_map.mytext)|not}

Tried it yet ?

--
Nicolas Pastorino
Director Community - eZ
Member of the Community Project Board

eZ Publish Community on twitter: http://twitter.com/ezcommunity

t : http://twitter.com/jeanvoye
G+ : http://plus.tl/jeanvoye

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 11:28:31
Script start
Timing: Jan 18 2025 11:28:31
Module start 'layout'
Timing: Jan 18 2025 11:28:31
Module start 'content'
Timing: Jan 18 2025 11:28:32
Module end 'content'
Timing: Jan 18 2025 11:28:32
Script end

Main resources:

Total runtime0.6291 sec
Peak memory usage4,096.0000 KB
Database Queries62

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0048 587.9063152.6250
Module start 'layout' 0.00480.0025 740.531339.4453
Module start 'content' 0.00730.6204 779.9766582.7969
Module end 'content' 0.62770.0014 1,362.773412.4766
Script end 0.6291  1,375.2500 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00330.5167160.0002
Check MTime0.00140.2206160.0001
Mysql Total
Database connection0.00060.102710.0006
Mysqli_queries0.577591.7963620.0093
Looping result0.00070.1041600.0000
Template Total0.592194.120.2961
Template load0.00210.338620.0011
Template processing0.590093.771920.2950
Template load and register function0.00010.018310.0001
states
state_id_array0.00080.127810.0008
state_identifier_array0.00080.126020.0004
Override
Cache load0.00180.2849210.0001
Sytem overhead
Fetch class attribute can translate value0.00080.131330.0003
Fetch class attribute name0.00140.221160.0002
XML
Image XML parsing0.00100.155630.0003
class_abstraction
Instantiating content class attribute0.00000.002770.0000
General
dbfile0.00100.1645220.0000
String conversion0.00000.001140.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
3content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
4content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
5content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
1content/datatype/view/ezxmltags/line.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/line.tplEdit templateOverride template
2content/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: 17
 Number of unique templates used: 7

Time used to render debug report: 0.0001 secs