test if attribute is set

Author Message

Lauren Matheson

Friday 09 January 2004 4:13:34 pm

What is the best way to test for existence of an attribute? I have been using:

{section show=$MinGroup:item.data_map.link|not}

This works, but naturally ez complains:

No such attribute for array(4): link
Choose one of following: name, intro, body, image

Lauren Matheson

Wednesday 14 January 2004 5:38:05 pm

my solution is: ... Wrong

{section show=$MinGroup:item.data_map|contains('link')}
will not work because we need to test against the keys of data_map, not the values. Back to the drawing board.

Lauren Matheson

Thursday 15 January 2004 6:38:29 am

Here is a solution that actually works. Apply the patch to add a keys operator, then use:

{section show=$MinGroup:item.data_map|keys|contains(link)}

The patch is filed in bug report:
http://ez.no/developer/ez_publish_3/bug_reports/keys_array_operator_patch_attached

Because alignment is not preserved when text is posted to the bug system, you will have to cut and paste the patch into your ezpublish implementation.

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 04:22:58
Script start
Timing: Jan 31 2025 04:22:58
Module start 'layout'
Timing: Jan 31 2025 04:22:58
Module start 'content'
Timing: Jan 31 2025 04:22:58
Module end 'content'
Timing: Jan 31 2025 04:22:58
Script end

Main resources:

Total runtime0.0141 sec
Peak memory usage2,048.0000 KB
Database Queries3

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0049 588.1328151.2109
Module start 'layout' 0.00490.0028 739.343836.6484
Module start 'content' 0.00770.0050 775.992290.0313
Module end 'content' 0.01270.0014 866.023429.9922
Script end 0.0140  896.0156 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.002618.2405140.0002
Check MTime0.00107.3749140.0001
Mysql Total
Database connection0.00085.603210.0008
Mysqli_queries0.002517.570930.0008
Looping result0.00000.086510.0000
Template Total0.00117.510.0011
Template load0.00085.752410.0008
Template processing0.00021.756410.0002
Override
Cache load0.00064.152010.0006
General
dbfile0.00106.869780.0001
String conversion0.00000.049240.0000
Note: percentages do not add up to 100% because some accumulators overlap

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 1
 Number of unique templates used: 1

Time used to render debug report: 0.0001 secs