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