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.