Ignore <br> tag?

Author Message

Douglas Johnson

Wednesday 27 August 2003 2:16:53 pm

I have a {section show statement set up to check if an attribute exists. If that attribute exists, the attribute is shown in the template. This works fine, however, I would like to be able to exclude any html tags that exist before and after the attribute....example: <br>{attribute_view_gui attribute = $content_version.data_map.header}</br>

If there is no header, I not only don't want to show the header, but NO <br> line breaks also. How can I exclude the line break using the section show statement? Or, some other statement?

Alex Jones

Wednesday 27 August 2003 2:26:18 pm

Try:

{section show=eq($:item.data_map.header.content,'')} {* Check the header field for content - if it is empty print this (in this case nothing is output): *}

{section-else} {* Else print header surrounded by breaks *}
<br>{attribute_view_gui attribute = $content_version.data_map.header}</br>
{/section}

Note, this could be shorter using 'ne' (not equal) in place of the 'eq' (equal) and eliminating the {section-else}, but I wrote it like this so you could have an example of how to display different things depending on whether or not a field has a value.

Alex

Alex
[ bald_technologist on the IRC channel (irc.freenode.net): #eZpublish ]

<i>When in doubt, clear the cache.</i>

Douglas Johnson

Thursday 28 August 2003 7:29:49 am

First I would like to thank you for your response. Without help from people like you, I would be out of a job.

The "section show=eq($:item.data_map.header.content,'')}" Thing did not work. Even if there wasn't any content, the <br> tag was still shown in the browser. I want to skip the line break if there is no content to be displayed. I'm begining to think this is not possible.

Also, how do I check for the existance of an image?

Alex Jones

Thursday 28 August 2003 7:53:31 am

No problem, we're all in the same boat! I've had a ton of help from other developers. :)

I'm not sure why the code I provided didn't work. Is your header text or an image? Also, have you tried looking at the attributes of the header? It might help you get an idea of what information you can detect for your show statement. Try: {$:item.data_map.header|attribute(show)} or {$:item.data_map|attribute(show)}

Here is some code that I am actually using in my templates to choose between possible images:

{section show=eq($:item.data_map.image,'')}
{attribute_view_gui attribute=$:item.data_map.image_1 image_class=proportionalmedium}
{section-else}
{attribute_view_gui attribute=$:item.data_map.image image_class=proportionalmedium}
{/section}

This code is detecting which image is available to display. I need the check as I am fetching several different types of class, one of which has multiple images (thus the 'image_1') while most only have a single image (thus just 'image').

So, I detect whether or not a field of 'image' contains any data. If it doesn't exist, or if it is empty it returns nothing and thus matches the show statement (specifically the '') so I display 'image_'1. The section-else displays 'image'.

Note: 'proportionalmedium' is a custom image class.

I hope this helps,

Alex

Alex
[ bald_technologist on the IRC channel (irc.freenode.net): #eZpublish ]

<i>When in doubt, clear the cache.</i>

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

Main resources:

Total runtime0.9353 sec
Peak memory usage4,096.0000 KB
Database Queries60

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0069 587.7891152.6094
Module start 'layout' 0.00690.0030 740.398439.4141
Module start 'content' 0.00990.9239 779.8125547.8203
Module end 'content' 0.93380.0015 1,327.632812.1875
Script end 0.9352  1,339.8203 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00380.4014160.0002
Check MTime0.00180.1974160.0001
Mysql Total
Database connection0.00100.106710.0010
Mysqli_queries0.872093.2321600.0145
Looping result0.00060.0596580.0000
Template Total0.898096.020.4490
Template load0.00230.245720.0011
Template processing0.895795.773520.4479
Template load and register function0.00100.102210.0010
states
state_id_array0.00140.146410.0014
state_identifier_array0.00130.134120.0006
Override
Cache load0.00180.1971330.0001
Sytem overhead
Fetch class attribute can translate value0.00050.052420.0002
Fetch class attribute name0.00160.172450.0003
XML
Image XML parsing0.00060.067220.0003
class_abstraction
Instantiating content class attribute0.00000.003360.0000
General
dbfile0.00090.0962160.0001
String conversion0.00000.000740.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
4content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
6content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
2content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
2content/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: 16
 Number of unique templates used: 6

Time used to render debug report: 0.0001 secs