How to test an media attribute ?

Author Message

Sébastien Antoniotti

Friday 08 December 2006 1:43:24 am

Hi,

In a custom class I have an attribute of type media that is not required, and displaying objects of this class, I want to test if this attribute (identifier : "son") contains a file or not.

I have tried this :

{section show=$node.data_map.son.content.filename.is_empty|not} 		        
		<object type="application/x-shockwave-flash" data="{'dewplayer.swf'|ezimage('no')}?mp3={$node.data_map.son.content.filepath|ezroot('no')}" width="200" height="18" bgcolor="#cccccc">
				<param name="movie" value="{'dewplayer.swf'|ezimage('no')}?mp3={$node.data_map.son.content.filepath|ezroot('no')}" />
				<param name="bgcolor" value="#cccccc"> 
		</object>{/section}

and this

{if gt($node.data_map.son.content.filesize,0)} 		        
		<object type="application/x-shockwave-flash" data="{'dewplayer.swf'|ezimage('no')}?mp3={$node.data_map.son.content.filepath|ezroot('no')}" width="200" height="18" bgcolor="#cccccc">
				<param name="movie" value="{'dewplayer.swf'|ezimage('no')}?mp3={$node.data_map.son.content.filepath|ezroot('no')}" />
				<param name="bgcolor" value="#cccccc"> 
		</object>{/if}

But my flash player always appears =(

eZ Publish Freelance
web : http://www.webaxis.fr

Kristof Coomans

Friday 08 December 2006 2:08:03 am

Hello Sébastien

You can use this:

{if $attribute.content.filename}
{* show the player *}
...
{else}
...
{/if}

independent eZ Publish developer and service provider | http://blog.coomanskristof.be | http://ezpedia.org

Sébastien Antoniotti

Friday 08 December 2006 3:01:13 am

It works very well !

Thanks a lot ;)

eZ Publish Freelance
web : http://www.webaxis.fr

kracker (the)

Friday 08 December 2006 3:09:28 am

<b>Added</b> node to eZpedia in a direct response from a user looking to abstract this into value for the next user.
<i>http://ezpedia.org/wiki/en/ez/solution_template_logic_to_test_object_attribute</i>

cheers,
//kracker

Member since: 2001.07.13 || http://ezpedia.se7enx.com/

Powered by eZ Publish™ CMS Open Source Web Content Management. Copyright © 1999-2014 eZ Systems AS (except where otherwise noted). All rights reserved.