Forums / General / Variable exists

Variable exists

Author Message

Carlos Revillo

Thursday 25 May 2006 2:12:34 am

Hi. Is there any way to know if a variable is defined?.

I'll try to explain it better.

I have a node. Path_identification_string for the node is ".../node"

But, sometimes, i have urls like "../node?var=x" and so on.

How can i know if i have params in my url or not?.
I was thinking in something like if is_defined(var) or something like that...

Thanks.

Marcin Drozd

Friday 26 May 2006 3:25:13 am

Hi Carlos

You can use a template operator is_set( target )
where target = ezhttp('var','get');
and var is name of your get variable from url

see more:
http://ez.no/doc/ez_publish/technical_manual/3_7/reference/template_operators/variable_and_type_handling/get_type
http://ez.no/doc/ez_publish/technical_manual/3_7/reference/template_operators/variable_and_type_handling/is_set
http://ez.no/doc/ez_publish/technical_manual/3_7/reference/template_operators/variable_and_type_handling/is_unset

http://ez-publish.pl

kracker (the)

Wednesday 31 January 2007 7:40:34 am

I tried Marcin's approach for testing if a variable exists with this code,

{if is_set( ezhttp( 'print', 'get' ) )}x{else}z{/if}

I also read a similar thread,
<i>http://ez.no/community/forum/general/how_to_test_for_existance_of_variable</i>

Yet this approach seems to throw a this error,

Error: eZTemplate:ezhttp    Jan 31 2007 10:31:16    Unknown get variable 'print'

Is it possible to test for a variable in template language in this way without throwing an error?

//kracker

<i>sage francis - sick of waiting tables - i apologize</i>

Member since: 2001.07.13 || http://ezpedia.se7enx.com/

Kristian Hole

Wednesday 31 January 2007 7:46:19 am

Implemented in 3.9:
http://pubsvn.ez.no/viewcvs/ezp/trunk/doc/features/3.9/added_away_to_check_existence_of_var_in_ezini_or_ezhttp.txt?view=markup

Kristian

http://ez.no/ez_publish/documenta...tricks/show_which_templates_are_used
http://ez.no/doc/ez_publish/techn...te_operators/miscellaneous/attribute