Optional content items - how to NOT display in a template?

Author Message

Pirkka Hartikainen

Tuesday 29 July 2003 5:42:11 am

Simple noobie question:

"I have an optional image field in my content class. I know how to display the image on the page using code like this:

<img src=/{$node.data_map.myimage.content[reference].full_path}>

How do I write a conditional statement that only outputs this line if the 'myimage' data item exists for the currently viewed node?"

I've tried this one, unsuccesfully:

{let ImageURL=$node.data_map.myimage.content[reference].full_path}
{section show=not(eq($ImageURL, ""))}
<img src=/{$ImageURL}>
{/section}

Bjørn Kaarstein

Tuesday 29 July 2003 6:47:46 am

Try something like this...

{section show=ne($node.data_map.myimage.content)}

<img src={$node.data_map.myimage.content[medium].full_path|ezurl} hspace="5" vspace="5" border=1 align=left>

{/section}

Regards Bjørn

Pirkka Hartikainen

Tuesday 29 July 2003 2:39:20 pm

Works!!! Thank you.

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

Main resources:

Total runtime0.9682 sec
Peak memory usage4,096.0000 KB
Database Queries57

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0074 589.5859152.6563
Module start 'layout' 0.00750.0050 742.242239.5078
Module start 'content' 0.01240.9544 781.7500466.7422
Module end 'content' 0.96680.0014 1,248.49228.0938
Script end 0.9682  1,256.5859 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00450.4625160.0003
Check MTime0.00230.2340160.0001
Mysql Total
Database connection0.00090.096310.0009
Mysqli_queries0.918994.9087570.0161
Looping result0.00060.0641550.0000
Template Total0.930396.120.4652
Template load0.00240.243120.0012
Template processing0.928095.842820.4640
Template load and register function0.00010.012610.0001
states
state_id_array0.00110.111110.0011
state_identifier_array0.00090.096620.0005
Override
Cache load0.00190.1991200.0001
Sytem overhead
Fetch class attribute can translate value0.00070.067920.0003
Fetch class attribute name0.00090.091630.0003
XML
Image XML parsing0.00020.025520.0001
class_abstraction
Instantiating content class attribute0.00000.000730.0000
General
dbfile0.00070.0677100.0001
String conversion0.00000.001240.0000
Note: percentages do not add up to 100% because some accumulators overlap

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
3content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
4content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
1content/datatype/view/ezxmltags/line.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/line.tplEdit templateOverride template
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 10
 Number of unique templates used: 5

Time used to render debug report: 0.0001 secs