Share » Forums » General » checking if an attributes value ie empty

checking if an attributes value ie empty

checking if an attributes value ie empty

Tuesday 10 May 2005 8:40:42 am - 5 replies

Author Message

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

You must be logged in to post messages in this topic!

36 542 Users on board!

Forums menu