Smarty Forum Index Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon.

array_key_exists

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> General
View previous topic :: View next topic  
Author Message
mech7
Smarty n00b


Joined: 11 Dec 2007
Posts: 3

PostPosted: Fri Jan 04, 2008 10:52 am    Post subject: array_key_exists Reply with quote

Is there a way to use this function inside templates? or any other function to check if the value exists?
Back to top
View user's profile Send private message
boots
Administrator


Joined: 16 Apr 2003
Posts: 5611
Location: Toronto, Canada

PostPosted: Fri Jan 04, 2008 3:01 pm    Post subject: Reply with quote

You mean like:

{if isset( $foo.bar ) }

or

{if $foo.bar|isset}

or

{if array_key_exists('bar', $foo ) }

or

{if 'bar'|array_key_exists:$foo}

?

Consider showing a more explicit example of your need.

HTH
Back to top
View user's profile Send private message
Aldekein
Smarty Rookie


Joined: 24 Jan 2008
Posts: 5
Location: Ukraine

PostPosted: Thu Jan 24, 2008 12:12 pm    Post subject: Reply with quote

boots wrote:
You mean like:

{if isset( $foo.bar ) }

or

{if $foo.bar|isset}


is there a way to get it to work?...

I wrote a custom modifier for the second case but it does not produce required results.
Back to top
View user's profile Send private message Visit poster's website
U.Tews
Administrator


Joined: 22 Nov 2006
Posts: 5068
Location: Hamburg / Germany

PostPosted: Thu Jan 24, 2008 3:32 pm    Post subject: Reply with quote

boots

For some reason isset can't be used as modifier. It creates the following error:

Fatal error: Smarty error: [in xxx.tpl line 3]: [plugin] modifier 'isset' is not implemented (core.load_plugins.php, line 118)
Back to top
View user's profile Send private message
Aldekein
Smarty Rookie


Joined: 24 Jan 2008
Posts: 5
Location: Ukraine

PostPosted: Fri Jan 25, 2008 8:31 am    Post subject: Reply with quote

U.Tews wrote:
boots

For some reason isset can't be used as modifier. It creates the following error:

Fatal error: Smarty error: [in xxx.tpl line 3]: [plugin] modifier 'isset' is not implemented (core.load_plugins.php, line 118)


if you write a custom plugin for smarty - you can, I tried. But it produces not that results that you expect...
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> General All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group
Protected by Anti-Spam ACP