Smarty: How to reference to the associative array index

Vlad picture Vlad · Mar 15, 2009 · Viewed 35.7k times · Source
Array $imagelist:

Array ( 
    [additional] => Array ( 
        [count] => 2 
        [image] => Array ( 
            [nokia_e61_1.jpg] => Array ( 
                [name_body] => nokia_e61_1 
                [name_ext] => jpg 
            ) 
            [nokia_e61_2.jpg] => Array ( 
                [name_body] => nokia_e61_2 
                [name_ext] => jpg 
            ) 
            [nokia_e61_3.jpg] => Array ( 
                [name_body] => nokia_e61_3 
                [name_ext] => jpg 
            ) 
            [nokia_e61_4.jpg] => Array ( 
                [name_body] => nokia_e61_4 
                [name_ext] => jpg 
            ) 
        ) 
    ) 
    [main] => nokia_e61 
) 

The value nokia_e61_1.jpg is kept in {$getvars.imagename}.

I wrote {$imagelist.additional.image.`$getvars.imagename`.name_body} but it doesn't work.

Please help.

Answer

Edoardo Vacchi picture Edoardo Vacchi · Mar 15, 2009

see if {$imagelist.additional.image[$getvars.imagename].name_body} works