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

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}

eZ debug

Timing: Jan 19 2025 03:35:54
Script start
Timing: Jan 19 2025 03:35:54
Module start 'content'
Timing: Jan 19 2025 03:35:56
Module end 'content'
Timing: Jan 19 2025 03:35:56
Script end

Main resources:

Total runtime2.0564 sec
Peak memory usage4,096.0000 KB
Database Queries200

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0088 589.3359180.7813
Module start 'content' 0.00891.8377 770.1172563.4766
Module end 'content' 1.84660.2098 1,333.5938337.3359
Script end 2.0563  1,670.9297 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00460.2228210.0002
Check MTime0.00180.0853210.0001
Mysql Total
Database connection0.00100.048610.0010
Mysqli_queries1.962795.44082000.0098
Looping result0.00230.11291980.0000
Template Total2.019798.221.0099
Template load0.00230.112920.0012
Template processing2.017498.102521.0087
Template load and register function0.00030.012910.0003
states
state_id_array0.00190.090410.0019
state_identifier_array0.00210.103420.0011
Override
Cache load0.00210.1007420.0000
Sytem overhead
Fetch class attribute can translate value0.00170.080930.0006
Fetch class attribute name0.00250.120660.0004
XML
Image XML parsing0.00090.044130.0003
class_abstraction
Instantiating content class attribute0.00000.001270.0000
General
dbfile0.00200.0971270.0001
String conversion0.00000.000330.0000
Note: percentages do not add up to 100% because some accumulators overlap

CSS/JS files loaded with "ezjscPacker" during request:

CacheTypePacklevelSourceFiles
CSS0extension/community/design/community/stylesheets/ext/jquery.autocomplete.css
extension/community_design/design/suncana/stylesheets/scrollbars.css
extension/community_design/design/suncana/stylesheets/tabs.css
extension/community_design/design/suncana/stylesheets/roadmap.css
extension/community_design/design/suncana/stylesheets/content.css
extension/community_design/design/suncana/stylesheets/star-rating.css
extension/community_design/design/suncana/stylesheets/syntax_and_custom_tags.css
extension/community_design/design/suncana/stylesheets/buttons.css
extension/community_design/design/suncana/stylesheets/tweetbox.css
extension/community_design/design/suncana/stylesheets/jquery.fancybox-1.3.4.css
extension/bcsmoothgallery/design/standard/stylesheets/magnific-popup.css
extension/sevenx/design/simple/stylesheets/star_rating.css
extension/sevenx/design/simple/stylesheets/libs/fontawesome/css/all.min.css
extension/sevenx/design/simple/stylesheets/main.v02.css
extension/sevenx/design/simple/stylesheets/main.v02.res.css
JS0extension/ezjscore/design/standard/lib/yui/3.17.2/build/yui/yui-min.js
extension/ezjscore/design/standard/javascript/jquery-3.7.0.min.js
extension/community_design/design/suncana/javascript/jquery.ui.core.min.js
extension/community_design/design/suncana/javascript/jquery.ui.widget.min.js
extension/community_design/design/suncana/javascript/jquery.easing.1.3.js
extension/community_design/design/suncana/javascript/jquery.ui.tabs.js
extension/community_design/design/suncana/javascript/jquery.hoverIntent.min.js
extension/community_design/design/suncana/javascript/jquery.popmenu.js
extension/community_design/design/suncana/javascript/jScrollPane.js
extension/community_design/design/suncana/javascript/jquery.mousewheel.js
extension/community_design/design/suncana/javascript/jquery.cycle.all.js
extension/sevenx/design/simple/javascript/jquery.scrollTo.js
extension/community_design/design/suncana/javascript/jquery.cookie.js
extension/community_design/design/suncana/javascript/ezstarrating_jquery.js
extension/community_design/design/suncana/javascript/jquery.initboxes.js
extension/community_design/design/suncana/javascript/app.js
extension/community_design/design/suncana/javascript/twitterwidget.js
extension/community_design/design/suncana/javascript/community.js
extension/community_design/design/suncana/javascript/roadmap.js
extension/community_design/design/suncana/javascript/ez.js
extension/community_design/design/suncana/javascript/ezshareevents.js
extension/sevenx/design/simple/javascript/main.js

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1node/view/full.tplfull/forum_topic.tplextension/sevenx/design/simple/override/templates/full/forum_topic.tplEdit templateOverride template
5content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
8content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
3content/datatype/view/ezxmltags/line.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/line.tplEdit templateOverride template
2content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
1pagelayout.tpl<No override>extension/sevenx/design/simple/templates/pagelayout.tplEdit templateOverride template
 Number of times templates used: 20
 Number of unique templates used: 6

Time used to render debug report: 0.0001 secs