|
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 |
atomp3 Smarty Regular
Joined: 04 May 2007 Posts: 60
|
Posted: Thu Aug 05, 2010 12:27 pm Post subject: object and variable |
|
|
Hi
I have variable {$data->somename}
and than
Code: |
{foreach from=$setall item=item}
<p>
{JAttributes d_name=$item.d_name type=$item.oid selected=$data->somename}
</p>
{/foreach}
|
I need to add in loop combination:
Code: | selected = $data->$item.name |
which is possible in php but i think not in smarty[/code]
Last edited by atomp3 on Sun Aug 08, 2010 3:28 am; edited 1 time in total |
|
Back to top |
|
U.Tews Administrator
Joined: 22 Nov 2006 Posts: 5068 Location: Hamburg / Germany
|
Posted: Thu Aug 05, 2010 4:27 pm Post subject: |
|
|
For Smarty 2 you need a workaround
Code: |
{foreach from=$setall item=item}
<p>
{assign var=foo value=$item.name}
{JAttributes d_name=$item.d_name type=$item.oid selected=$data->$foo}
</p>
{/foreach}
|
In Smarty3 you can use
Code: |
{foreach from=$setall item=item}
<p>
{JAttributes d_name=$item.d_name type=$item.oid selected=$data->$item.name}
</p>
{/foreach}
|
|
|
Back to top |
|
atomp3 Smarty Regular
Joined: 04 May 2007 Posts: 60
|
Posted: Fri Aug 06, 2010 5:49 am Post subject: |
|
|
Thanks a lot it's working |
|
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
|