RE: [SMARTY] Looping through an array of objects
| From: | Philippe Desaulniers | Date: | Thu, 17 Oct 2002 15:08:31 +0000 |
| Subject: | RE: [SMARTY] Looping through an array of objects | ||
| References: | 1 | Groups: | php.smarty.general |
| Request: | Send a blank email to php-smarty-general+get-6189@lists.php.net to get a copy of this message | ||
Thanks, that works.
I think I caught on to something: { section } assumes that $myObjArray is
indexed by integer values, starting at 0... ...since the two items I had
in $myObjArray happened to have indexes '5' and '6', { section } never saw
them.
I'd have to test it, but maybe with proper indexes ('0' and '1') the code
I posted actually works...
thanks again
phil
> -----Original Message-----
> From: Josh Johnson [mailto:mailing_lists@allusiveimage.com]
> Sent: October 17, 2002 10:55 AM
> To: 'Philippe Desaulniers'; smarty-general@lists.php.net
> Subject: RE: [SMARTY] Looping through an array of objects
>
>
> I'd use a foreach...
>
> {foreach from=$myObjArray item=this_object}
> <li>{$this_object->property}</li>
> {/foreach}
>
> -----Original Message-----
> From: Philippe Desaulniers [mailto:filou@histrion.org]
> Sent: Wednesday, October 16, 2002 11:30 PM
> To: smarty-general@lists.php.net
> Subject: [SMARTY] Looping through an array of objects
>
> Hello,
>
> I'm trying to loop in a section, through an array of objects. Is there
> any way to get to my object properties?
>
> An example of what I'd like it to do is this:
>
> {section name=sec1 loop=$myObjArray}
> <li>{$myObjectArray[sec1]->myObjectProperty}
> {/section}
>
> Thanks,
>
> phil
>
>
>
>
> --
> Smarty General Mailing List (http://smarty.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
>
> --
> Smarty General Mailing List (http://smarty.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>