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.

eZ debug

Timing: Jan 30 2025 19:37:43
Script start
Timing: Jan 30 2025 19:37:43
Module start 'layout'
Timing: Jan 30 2025 19:37:43
Module start 'content'
Timing: Jan 30 2025 19:37:43
Module end 'content'
Timing: Jan 30 2025 19:37:43
Script end

Main resources:

Total runtime0.0292 sec
Peak memory usage6,144.0000 KB
Database Queries3

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0071 588.2500151.2266
Module start 'layout' 0.00710.0064 739.4766220.7188
Module start 'content' 0.01350.0139 960.1953997.9297
Module end 'content' 0.02740.0017 1,958.125033.9922
Script end 0.0292  1,992.1172 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.002910.0658140.0002
Check MTime0.00124.0521140.0001
Mysql Total
Database connection0.00072.439810.0007
Mysqli_queries0.005920.185630.0020
Looping result0.00000.075110.0000
Template Total0.00134.310.0013
Template load0.00103.309610.0010
Template processing0.00030.989010.0003
Override
Cache load0.00062.163110.0006
General
dbfile0.00144.886980.0002
String conversion0.00000.036740.0000
Note: percentages do not add up to 100% because some accumulators overlap

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 1
 Number of unique templates used: 1

Time used to render debug report: 0.0001 secs