|
Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon. |
|
View previous topic :: View next topic |
Author |
Message |
gt Smarty n00b
Joined: 17 Oct 2003 Posts: 4
|
Posted: Fri Oct 17, 2003 7:57 am Post subject: How to detect a array key name into section? |
|
|
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 |
|
andre Smarty Pro
Joined: 23 Apr 2003 Posts: 164 Location: Karlsruhe, Germany
|
Posted: Fri Oct 17, 2003 8:03 am Post subject: |
|
|
*EDIT* Just noticed it's an assoc array
{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 |
|
gt Smarty n00b
Joined: 17 Oct 2003 Posts: 4
|
Posted: Fri Oct 17, 2003 9:37 am Post subject: |
|
|
thanx, andre. |
|
Back to top |
|
|
|
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
|