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

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

Main resources:

Total runtime0.9869 sec
Peak memory usage4,096.0000 KB
Database Queries66

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0058 589.2813152.6406
Module start 'layout' 0.00580.0029 741.921939.4609
Module start 'content' 0.00880.9767 781.3828588.8750
Module end 'content' 0.98550.0013 1,370.257816.1406
Script end 0.9868  1,386.3984 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00340.3405160.0002
Check MTime0.00140.1461160.0001
Mysql Total
Database connection0.00090.087710.0009
Mysqli_queries0.917092.9260660.0139
Looping result0.00060.0633640.0000
Template Total0.953196.620.4765
Template load0.00230.231520.0011
Template processing0.950896.343720.4754
Template load and register function0.00020.016810.0002
states
state_id_array0.00110.108510.0011
state_identifier_array0.00140.141820.0007
Override
Cache load0.00200.2041570.0000
Sytem overhead
Fetch class attribute can translate value0.00100.104720.0005
Fetch class attribute name0.00140.139080.0002
XML
Image XML parsing0.00260.261820.0013
class_abstraction
Instantiating content class attribute0.00000.0048120.0000
General
dbfile0.00240.2427220.0001
String conversion0.00000.000840.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
6content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
6content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
10content/datatype/view/ezxmltags/line.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/line.tplEdit templateOverride template
15content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
3content/datatype/view/ezxmltags/literal.tpl<No override>extension/community/design/standard/templates/content/datatype/view/ezxmltags/literal.tplEdit templateOverride template
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 42
 Number of unique templates used: 7

Time used to render debug report: 0.0001 secs