Re: [SMARTY] Re: Deep access of associative array value by dynamic index.
| From: | messju mohr | Date: | Wed, 28 Apr 2004 17:44:04 +0000 |
| Subject: | Re: [SMARTY] Re: Deep access of associative array value by dynamic index. | ||
| References: | 1 2 | Groups: | php.smarty.general |
| Request: | Send a blank email to php-smarty-general+get-11319@lists.php.net to get a copy of this message | ||
On Wed, Apr 28, 2004 at 09:59:41AM -0700, boots wrote:
> Actually, Tom's example worked for me as-is. I think that array access
> with [$foo.bar] was added at 2.6.1 (or possible 2.6.0 -- messju will
> recall better than I).
NEWS and cvs recall best :) it was the last thing that went into
2.6.0-RC3 before release.
> xo boots
>
> --- pete M <pmorgan@ukds.net> wrote:
> > try
> > $foo.building.selection[0]
> > pete
> >
> > Tom wrote:
> > > Hello
> > >
> > > I need some help with making good use of associative arrays in
> > Smarty.
> > >
> > >
> > > I have an array created that might partly look something like this:
> > >
> > > $foo['building']['selected'] = 10;
> > > $foo['building']['selection'] = array ( 42=>'small',
> > > 10=>'medium',
> > > 24=>'large');
> > > $foo['allowEdit'] = 'no';
> > >
> > > The script then simply assigns:
> > > $smarty->assign('foo', $foo);
> > >
> > > And and my template contents is a little like this:
> > >
> > > <html>
> > > <body>
> > > Size of building is :
> > > {if $foo.allowEdit == 'yes'}
> > > <select name="buildingSize">
> > > {html_options options=
$foo.building.selection
> > > selected=$foo.building.selected}
> > > </select>
> > > {else}
> > > {$foo.building.selection[$foo.building.selected]}
> > > {/if}
> > > </body>
> > > </html>
> > >
> > > Which (obviously) doesn't work. Can anyone help? :)
> > >
> > > MTIA
> > > Tom
> >
> > --
> > Smarty General Mailing List (http://smarty.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php
> >
>
>
>
>
>
> __________________________________
> Do you Yahoo!?
> Win a $20,000 Career Makeover at Yahoo! HotJobs
> http://hotjobs.sweepstakes.yahoo.com/careermakeover
>
> --
> Smarty General Mailing List (http://smarty.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php