|
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 |
sarahfoxnz Smarty Regular
Joined: 11 Apr 2010 Posts: 76
|
Posted: Thu Nov 08, 2018 4:09 am Post subject: How do i assign a sub-array within Smarty? |
|
|
Hello, I've got:-
Code: |
<ul>
{foreach from=$gotlist key=k item=v}
<li>{$k} {$v}</li>
{/foreach}
</ul>
|
Code: |
{assign "gotlist.name" "2"}
|
Code: |
<ul>
{foreach from=$gotlist key=k item=v}
<li>{$k} {$v}</li>
{/foreach}
</ul>
|
However when $gotlist.name comes up again, it is still 1.
what i CAN do is assign values to a single variable, but im having problems assigning to a sub-array.
Ive tried
Code: |
{assign "gotlist.name" "2"}
{assign "$gotlist.name" "2"}
{assign name="$gotlist.name" value="2"}
{assign name=$gotlist.name value="2"}
{assign name="gotlist.name" value="2"}
|
can anyone advise. |
|
Back to top |
|
AnrDaemon Administrator
Joined: 03 Dec 2012 Posts: 1785
|
Posted: Thu Nov 08, 2018 4:23 am Post subject: Re: How do i assign a sub-array within Smarty? |
|
|
Code: | {$gotlist["name"]="2"}
<ul>
{foreach $gotlist as $k => $v}
<li>{$k} {$v}</li>
{/foreach}
</ul> |
|
|
Back to top |
|
sarahfoxnz Smarty Regular
Joined: 11 Apr 2010 Posts: 76
|
Posted: Thu Nov 08, 2018 4:40 am Post subject: |
|
|
Thank you. |
|
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
|