How to find out if XML block is empty

Author Message

marcus klinge

Thursday 26 March 2009 6:43:52 am

Hello.

I am currently trying to avoid the output of an XML Block element alltogether if it is empty.

I tried:

{if ne( $node.data_map.positions,'' )}
    {attribute_view_gui attribute=$node.data_map_positions}
{/if}

as well as

{if ne( $node.data_map.positions.output.output_text,'' )}
    {attribute_view_gui attribute=$node.data_map_positions}
{/if}

But to no success.

Anyone?

Best,
Marcus

Jean-Luc Nguyen

Thursday 26 March 2009 7:02:58 am

Hello,

Try this one:

{if eq( $node.data_map.positions.has_content, 1)}
    {attribute_view_gui attribute=$node.data_map_positions}
{/if}

$node.data_map.positions.has_content is a boolean.

http://www.acidre.com

marcus klinge

Thursday 26 March 2009 7:37:09 am

That works.

Thank you!

Marcus

Mario Ivancic

Monday 30 March 2009 2:18:49 pm

Hi,

Just a little tip: It will work without eq operator:

{if $node.data_map.positions.has_content}
   {attribute_view_gui attribute=$node.data_map_positions}
{/if}

--
http://www.escapestudio.net
http://twitter.com/MarioIvancic

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