Re: [SMARTY] Appending and prepending on a section?
| From: | Travis Low | Date: | Wed, 31 Jul 2002 06:19:09 +0000 |
| Subject: | Re: [SMARTY] Appending and prepending on a section? | ||
| References: | 1 2 3 4 5 | Groups: | php.smarty.general |
| Request: | Send a blank email to php-smarty-general+get-5528@lists.php.net to get a copy of this message | ||
Thanks for explaining. Yes, that is a problem.
I feel sections work best with associative arrays. Dealing with nonzero-based numeric arrays is a pain. Perhaps a "base" attribute would fix it. If you specify a "base", then a numeric array would be assumed, and the loop would start at the specified base. For example, if you specified 'base="1"' for section foo, then $smarty.section.foo.index would equal 1 when $smarty.section.foo.iteration was also equal to 1. Hope that makes sense, I'm a little tired.
cheers,
Travis
Hendy Irawan wrote:
smarty-general,-- Travis Low <mailto:travis@dawnstar.org> <http://dawnstar.org/travis>I don't understand what you mean when you say "[section] messes up associative arrays". Would you please elaborate?Instead of looping through each entry, a {section} assumes the array starts from 0 to count($array)-1. so if I have an array like this $array = array(1=>'hello', 2=>'yahoo'); what will happen if it's put into a {section} ? First entry: (blank) Second entry: 'hello' 'yahoo' will never be output/processed, since {section} assumes the array starts from 0 to 1. I'm not sure how associative arrays (with string indexes) are processed by section, but judging by the above results, I think sections are only good for super-formally-numeric-indexed arrays (C-style arrays). using foreach, any array is ok. Salam hangat, Hendy Irawan - www.GaulDong.NET Kantor: (021) 5260467 [SoftVation] Kos: (021) 5261839 [kamar 3]