Forums / Setup & design / Ignore <br> tag?

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>

eZ debug

Timing: Jan 18 2025 16:16:10
Script start
Timing: Jan 18 2025 16:16:10
Module start 'content'
Timing: Jan 18 2025 16:16:11
Module end 'content'
Timing: Jan 18 2025 16:16:11
Script end

Main resources:

Total runtime1.4671 sec
Peak memory usage4,096.0000 KB
Database Queries197

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0058 587.5859180.8516
Module start 'content' 0.00581.2812 768.4375552.8828
Module end 'content' 1.28700.1800 1,321.3203336.7734
Script end 1.4670  1,658.0938 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00430.2962210.0002
Check MTime0.00150.1043210.0001
Mysql Total
Database connection0.00070.050710.0007
Mysqli_queries1.393694.99181970.0071
Looping result0.00210.14121950.0000
Template Total1.437198.020.7186
Template load0.00200.134320.0010
Template processing1.435197.820920.7176
Template load and register function0.00020.010910.0002
states
state_id_array0.00110.074410.0011
state_identifier_array0.00120.079120.0006
Override
Cache load0.00160.1105330.0000
Sytem overhead
Fetch class attribute can translate value0.00130.090330.0004
Fetch class attribute name0.00230.155850.0005
XML
Image XML parsing0.00080.054530.0003
class_abstraction
Instantiating content class attribute0.00000.001160.0000
General
dbfile0.00310.2112270.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
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
1pagelayout.tpl<No override>extension/sevenx/design/simple/templates/pagelayout.tplEdit templateOverride template
 Number of times templates used: 16
 Number of unique templates used: 6

Time used to render debug report: 0.0002 secs