|
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 |
assbach Smarty Rookie
Joined: 21 Jun 2003 Posts: 11
|
Posted: Wed Jul 09, 2003 3:34 pm Post subject: another array problem with section |
|
|
hi,
i just dont get it - pardon!
look, i have arrays like
Code: | rank[0] = "alt text1";
rank[1] = "alt text2";
..
rank[5] = "alt text5"; |
and
Code: | $szRankVals[group][area] = array(4,3,4,0,4,3,1,4,5,0,4,2); |
now i want to display the values within the template like
Code: | <td><img src="$val" alt="rank[$val]"></td> |
i tried to loop through a section but it did not throw out the values...
what is the right syntax?
Code: |
{section name=id loop=$szRankVals[group][area]}
<td><img src="{$szRankVals[group][area][id]}" alt=""></td>
{/section}
|
please help |
|
Back to top |
|
messju Administrator
Joined: 16 Apr 2003 Posts: 3336 Location: Oldenburg, Germany
|
Posted: Wed Jul 09, 2003 4:38 pm Post subject: |
|
|
"[]" is for section indices, "." is for hash-array dereference (consult the fine smarty-manual if unsure). so maybe what you want is:
loop=$szRankVals.group.area and {$szRankVals.group.area[id]} |
|
Back to top |
|
assbach Smarty Rookie
Joined: 21 Jun 2003 Posts: 11
|
Posted: Thu Jul 10, 2003 7:44 am Post subject: |
|
|
it's a simple as that?!
thanks a lot, it works! |
|
Back to top |
|
assbach Smarty Rookie
Joined: 21 Jun 2003 Posts: 11
|
Posted: Thu Jul 10, 2003 10:14 am Post subject: |
|
|
one problem left which i couldnt find any help in the doc about...
there also is the first array $rank
with which i want to assign the alt attribute in the img tag.
i need {$szRankVals.group.area[id]} within the $Rank[ ] brackets....
you know?
this does not work!
{$rank[$szRankVals.group.area[id]]}
or
{$rank[$szRankVals.group.area.id]}
what is the way? |
|
Back to top |
|
messju Administrator
Joined: 16 Apr 2003 Posts: 3336 Location: Oldenburg, Germany
|
Posted: Thu Jul 10, 2003 10:31 am Post subject: |
|
|
you have to assign an intermediate value to get this done with smarty. sth like:
Code: | {assign var=area value=$szRankVals.group.area[id]}
{$rank[$area]} |
|
|
Back to top |
|
assbach Smarty Rookie
Joined: 21 Jun 2003 Posts: 11
|
Posted: Thu Jul 10, 2003 10:40 am Post subject: |
|
|
this is what i was looking for....
thanks again!!!!! |
|
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
|