Re: [SMARTY] Variable variables

From: Date: Mon, 24 Mar 2003 14:14:12 +0000
Subject: Re: [SMARTY] Variable variables
References: 1  Groups: php.smarty.general 
Request: Send a blank email to php-smarty-general+get-8861@lists.php.net to get a copy of this message
On Mon, Mar 24, 2003 at 02:56:49PM +0100, Thorsten Schmidt wrote: > Dear, > is there a way to realise this: > > {section name=pages loop=10} > {assign var="row" value=$smarty.section.pages.rownum} > <TR> > <TD>{$array.value.param_$row_from}"></TD> > <TD>{$array.value.param_$row_to}"></TD> > </TR> > {/section} > > The array is build up like this: > $array['value']['param_1_from'] > $array['value']['param_1_to'] > $array['value']['param_2_from'] > $array['value']['param_2_to'] ... > > I tried with {$array.value.param_$row_from} but it also > didn't work : backticks are only for varnames inside quotes, to distinguish the varname from the string-contents that follow ("$foobar" vs. "$foobar") if you really need to, you can do sth. like. ... {assign var="row" value=$smarty.section.pages.rownum} {assign var="row_from" value="param_$row_from"} {assign var="row_to" value="param_$row_to"} <TR> <TD>{$array.value.$row_from}"></TD> <TD>{$array.value.$row_to}"></TD> </TR> ... but it would be better (for access from smarty) to build up the structure above similar to: $array['value'][1]['from']... $array['value'][1]['from']... $array['value'][2]['to']... $array['value'][2]['to']... and then use {$array.value.$row.from} have fun messju > Smarty version is 2.5.0 RC 1. > > > Best regards > > > Thorsten

« previous php.smarty.general (#8861) next »