|
Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon. |
|
View previous topic :: View next topic |
Author |
Message |
conrad10781 Smarty n00b
Joined: 24 Jun 2006 Posts: 4
|
Posted: Tue Jul 18, 2006 5:33 pm Post subject: 2 Smarty Variables in 1 {} |
|
|
in a SMARTY section is there anyway to pass 2 variables in the same { } IE $variable and $number as {$variable_$number}
{$variable}_{$number} is not giving the results I think i am looking for
Code: |
<input type="text" name="feet_{$smarty.section.a.iteration}" value="{$feet}" size="10">
|
is what I have that works in the name= field
but on the value=" I am looking for $feet_$smarty.section.a.iteration and
Code: |
{$feet_$smarty.section.a.iteration}
|
is not working for me |
|
Back to top |
|
tsudeki Smarty Rookie
Joined: 22 Mar 2006 Posts: 13
|
Posted: Tue Jul 18, 2006 7:18 pm Post subject: |
|
|
It would be helpful if you could post some more of the code around that line so we could get a better idea of what you're trying to achieve. If you're just trying to print 2 variables then the best way is:
Code: | {$variable1}_{$variable2} |
Or you could use the modifier cat to put the 2 together:
Code: | {$variable1|cat:"_"|cat:$variable2} |
Not sure if this is what you're looking for but without more information I dunno what else to tell ya. :/ |
|
Back to top |
|
boots Administrator
Joined: 16 Apr 2003 Posts: 5611 Location: Toronto, Canada
|
Posted: Tue Jul 18, 2006 7:38 pm Post subject: |
|
|
He's trying to do a var-var and Smarty doesn't support that. Use an array instead. So where you might have:
Quote: | $foo_1 = foo
$foo_2 = bar
$foo_3 = baz
$foo_4 = zub |
rather use:
Quote: | $foo = array(
'1'=>'foo',
'2'=>'bar',
'3'=>'baz',
'4'=>'zub' )
|
So that you can then do:
Code: | {assign var=num value=3}
{$foo.$num} |
|
|
Back to top |
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|