another newbie question: how do I perform selective displaying of content

Author Message

Nick Woods

Thursday 29 January 2004 12:04:17 pm

Although an experienced developer in jsp and html I'm new to PHP and ezpublish.

I apologise that this is a very basic question but I'm still getting to grips with where ez stops and php starts.

What I want to do is test to see if a dataitem is populated or not, and if it is display some html

in other words, is a sort of 'jsp/php/ezpublish mixup language ' I'd do something like this
<% if( !node.object.data_map.body.equals("")) {
/* body is present, display it */
%>
<TR>
<TD>Here is the body</TD>
<td>{attribute_view_gui attribute=$node.object.data_map.body}</td>
</tr>
<% }; %>

As you can see from the example above, I want to eliminate rows in my table to save space. In the 'real' example there may be more than one row to omit, eg. I might have a blank row for spacing or an <HR> tag

ull if node.object.data_map.body is populated then include html such as a table row

Eirik Alfstad Johansen

Friday 30 January 2004 1:12:48 am

Hi Nick,

Check out the section template function and the show parameter:

http://www.ez.no/ez_publish/documentation/development/libraries/ez_template/functions/section

Sincerely,

Eirik Johansen

Sincerely,

Eirik Alfstad Johansen
http://www.netmaking.no/

Nick Woods

Friday 30 January 2004 5:23:06 am

Thanks Eirik, it looks like all i have to do is something like this. I'm assuming that the 'body' field in my example will be null if it has no data, otheriwse I need to find another way of doing it

{section name="body" show=$node.object.data_map.body}
<tr><td>etc etc etc</td></tr>
{/section}

Eirik Alfstad Johansen

Friday 30 January 2004 5:45:12 am

Hi,

You might need to use some operator, depending on which datatype the body attribute is built upon. Read up on the is_set operator and other operators here:

http://ez.no/ez_publish/documentation/development/libraries/ez_template/operators/type_handling

Sincerely,

Eirik Johansen

Sincerely,

Eirik Alfstad Johansen
http://www.netmaking.no/

Nick Woods

Sunday 01 February 2004 3:53:27 am

After a lot of messing about I ended up with this for text fields (where intro is the name of my field) :-

{section show=ne($node.object.data_map.intro.content.output.output_text | trim | count_chars,0)}

and for images this seems to work :-

{let image_1_Content=$node.data_map.image_1.content}
{section show=$image_1_Content.is_valid}

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 18 2025 22:18:36
Script start
Timing: Jan 18 2025 22:18:36
Module start 'layout'
Timing: Jan 18 2025 22:18:36
Module start 'content'
Timing: Jan 18 2025 22:18:36
Module end 'content'
Timing: Jan 18 2025 22:18:36
Script end

Main resources:

Total runtime0.0373 sec
Peak memory usage2,048.0000 KB
Database Queries3

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0082 588.4063152.6875
Module start 'layout' 0.00820.0074 741.093839.5234
Module start 'content' 0.01560.0197 780.617293.4297
Module end 'content' 0.03530.0020 874.046934.3047
Script end 0.0373  908.3516 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.003910.3923140.0003
Check MTime0.00236.0347140.0002
Mysql Total
Database connection0.00154.104110.0015
Mysqli_queries0.005214.018030.0017
Looping result0.00000.053610.0000
Template Total0.00154.110.0015
Template load0.00092.349610.0009
Template processing0.00061.705910.0006
Override
Cache load0.00061.604310.0006
General
dbfile0.006316.789880.0008
String conversion0.00000.031940.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