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

How to detect a array key name into section?

 
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
gt
Smarty n00b


Joined: 17 Oct 2003
Posts: 4

PostPosted: Fri Oct 17, 2003 7:57 am    Post subject: How to detect a array key name into section? Reply with quote

It's incorrect:
{section name=sec loop=$assoc_array}
{if $assoc_array[sec.index]=="somekey"}ok!{/if}
{if $smarty.section.sec.index=="somekey"}ok!{/if}
{/section}
Back to top
View user's profile Send private message
andre
Smarty Pro


Joined: 23 Apr 2003
Posts: 164
Location: Karlsruhe, Germany

PostPosted: Fri Oct 17, 2003 8:03 am    Post subject: Reply with quote

*EDIT* Just noticed it's an assoc array Smile

{foreach from=$assoc_array item="sec"}
{if $sec == "somekey"}ok!{/if}
{/foreach}

You need to use {foreach} for associative arrays. {section} works only for "normal" arrays.
Back to top
View user's profile Send private message
gt
Smarty n00b


Joined: 17 Oct 2003
Posts: 4

PostPosted: Fri Oct 17, 2003 9:37 am    Post subject: Reply with quote

thanx, andre.
Back to top
View user's profile Send private message
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