Share » Forums » Developer » how to know if a variable is set?

how to know if a variable is set?

how to know if a variable is set?

Thursday 16 October 2008 8:21:28 am - 3 replies

Author Message

justin kazadi

Thursday 16 October 2008 8:40:51 am

Hi,
if you want to know if an attribute named title for exemple is set you can use this:

{if $node.data_map.title.has_content}
{do same thing}
{/if}

The theory is when we know everything and nothing works.
The practice is when everything works and nobody knows why.
If the practice and theory are met, nothing works and we do not know why.

Albert Einstein

Piotrek Karaƛ

Thursday 16 October 2008 10:31:35 am

Justin,
If you explicitly refer in a conditional statement to an inexistent variable, a warning or a notice will be thrown. This is exactly why isset-like functions exist, and eZ has those as well:
http://ez.no/doc/ez_publish/technical_manual/4_0/reference/template_operators/variable_and_type_handling/is_set
http://ez.no/doc/ez_publish/technical_manual/4_0/reference/template_operators/variable_and_type_handling
http://ez.no/doc/ez_publish/technical_manual/4_0/reference/template_operators/data_and_information_extraction/ezhttp_hasvariable
http://ez.no/doc/ez_publish/technical_manual/4_0/reference/template_operators/data_and_information_extraction/ezini_hasvariable
...
Hope this helps,
Cheers,
Piotrek

--
Company: mediaSELF Sp. z o.o., http://www.mediaself.pl
eZ references: http://ez.no/partners/worldwide_partners/mediaself
eZ certified developer: http://ez.no/certification/verify/272585
eZ blog: http://ez.ryba.eu

marc marc

Friday 17 October 2008 1:27:40 am

thank you for your help, i try right now

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

36 542 Users on board!

Forums menu