Forums / Developer / test if attribute is set
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): linkChoose one of following: name, intro, body, image
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.
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.
Script start
Module start 'content'
Module end 'content'
Script end
Time used to render debug report: 0.0001 secs