Forums / General / checking if an attributes value ie empty

checking if an attributes value ie empty

Author Message

zaxofeel .v

Tuesday 10 May 2005 8:40:42 am

hi all
i've this problem:
i've written this code:

{section show =$parent.object.data_map.site_image.content.is_empty|not}
{attribute_view_gui attribute=$parent.object.data_map.site_image}
{section-else}
{attribute_view_gui attribute=$grand.data_map.site_image}
{/section}

the aim of this code is to display an attribute called site image of the parent of current node
if the attribute is empty i want it to display the grand parent's site image

<b>but it is not working</b>
please ppl if u can help me on that, i'll be thankful.

thanks in advance.

Bruce Morrison

Tuesday 10 May 2005 4:36:37 pm

I have always used (since 3.3?) "has_content" to check if an attribute has any content.

So your code would read:

{section show=$parent.object.data_map.site_image.has_content}
{attribute_view_gui attribute=$parent.object.data_map.site_image}
{section-else}
{attribute_view_gui attribute=$grand.data_map.site_image}
{/section}

Cheers
Bruce

My Blog: http://www.stuffandcontent.com/
Follow me on twitter: http://twitter.com/brucemorrison
Consolidated eZ Publish Feed : http://friendfeed.com/rooms/ez-publish

zaxofeel .v

Wednesday 11 May 2005 12:27:17 am

first, thanks alot for your help.
but unfortunately it is not working.
the first part of the code is working fine, if the parent has content it is displayed,
but the other case (if parent is empty) it never displayes anything in the section else

thanks alot.

Bruce Morrison

Wednesday 11 May 2005 12:58:45 am

It's probably not working because $grand is not set. You are setting this to the grandparent aren't you?

Try adding {$grand|attribute(show,2)} to the template to see what value it has. Also turning on debugging will really help as it will tell you if you are tring to access variables that do not exist etc.

Cheers
Bruce

My Blog: http://www.stuffandcontent.com/
Follow me on twitter: http://twitter.com/brucemorrison
Consolidated eZ Publish Feed : http://friendfeed.com/rooms/ez-publish

zaxofeel .v

Wednesday 11 May 2005 1:23:30 am

I do understand what you mean very well, but i noticed that it doesn't display anything in the section else even any static content
like that:

{section show =$parent.object.data_map.site_image.content.is_empty|not}
{attribute_view_gui attribute=$parent.object.data_map.site_image}
{section-else}
1251
{/section}

even that static content is not displayed.

Bruce Morrison

Thursday 12 May 2005 6:00:29 pm

>...i noticed that it doesn't display anything in the section else even any static content

You have

{section show =$parent.object.data_map.site_image.content.is_empty|not}

I supplied

{section show=$parent.object.data_map.site_image.has_content}

If you have made that change and simply cut n' pasted the wrong code and it's still not working, post the debug output.

Cheers
Bruce

My Blog: http://www.stuffandcontent.com/
Follow me on twitter: http://twitter.com/brucemorrison
Consolidated eZ Publish Feed : http://friendfeed.com/rooms/ez-publish

eZ debug

Timing: Jan 19 2025 12:44:03
Script start
Timing: Jan 19 2025 12:44:03
Module start 'content'
Timing: Jan 19 2025 12:44:03
Module end 'content'
Timing: Jan 19 2025 12:44:03
Script end

Main resources:

Total runtime0.2746 sec
Peak memory usage2,048.0000 KB
Database Queries141

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0131 589.0625180.8203
Module start 'content' 0.01310.0046 769.8828102.0078
Module end 'content' 0.01770.2568 871.8906531.1250
Script end 0.2745  1,403.0156 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00331.2133200.0002
Check MTime0.00140.4950200.0001
Mysql Total
Database connection0.00682.487210.0068
Mysqli_queries0.222180.89951410.0016
Looping result0.00150.53191390.0000
Template Total0.256593.410.2565
Template load0.00090.311510.0009
Template processing0.255693.095110.2556
Override
Cache load0.00060.216610.0006
Sytem overhead
Fetch class attribute can translate value0.00110.411910.0011
XML
Image XML parsing0.00020.075010.0002
General
dbfile0.00281.0092200.0001
String conversion0.00000.002630.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
1pagelayout.tpl<No override>extension/sevenx/design/simple/templates/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