Re: section/array/isset problem
| From: | Travis Low | Date: | Wed, 27 Feb 2002 05:23:13 +0000 |
| Subject: | Re: section/array/isset problem | ||
| Groups: | php.smarty.general | ||
| Request: | Send a blank email to php-smarty-general+get-2855@lists.php.net to get a copy of this message | ||
I didn't see this addressed in the archives. I ran into this too. I had an array $MonthNames and a numeric index $month. This was my workaround:
{{section name="m" loop=$MonthNames}}
{{if $smarty.section.m.index == $month}}
<b>{{$MonthNames[m]}} {{$year}}</b>
{{/if}}
{{/section}}
Not very aesthetically pleasing, but it works. Everything is a matter of a little programming. :-)
Sorry about the double braces, but it's easier on my old eyes, and it spares me the bother of escaping javascript.
cheers,
Travis
Andrei Zmievski <andrei@ispi.net> wrote:
On Sun, 20 Jan 2002, Kai Kramhoeft wrote:-- Travis Low <mailto:travis@dawnstar.org> <http://dawnstar.org/travis>I want to check if a variable is set. I am using the following line: {if isset($check_project[$projects[listing].id])} Smarty is complaining that this is not a valid command. ... What am I doing wrong ? Thanks for your help,You can't use an arbitrary expression as an index in the array - Smarty is not really a programming language in that regard.. -Andrei "Everything is a matter of a little programming" -- Rasmus Lerdorf