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.