|
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 |
appel Smarty Rookie
Joined: 27 May 2003 Posts: 29
|
Posted: Tue Jul 01, 2003 4:07 pm Post subject: Passing smarty variables to an include var |
|
|
So, this is my code:
Code: |
<ul>
{section name=i loop=$tree}
<li>{$tree[i].page_name}</li>
{include file="children.tpl" pages="$tree[i].Children"}
{/section}
</ul>
|
But passing $tree[i].Children as the variable "pages" to children.tpl doesn't work. What do I do? |
|
Back to top |
|
Scott Smarty Rookie
Joined: 18 Apr 2003 Posts: 10 Location: Sarasota, FL
|
Posted: Tue Jul 01, 2003 10:17 pm Post subject: Re: Passing smarty variables to an include var |
|
|
appel wrote: | So, this is my code:
Code: |
<ul>
{section name=i loop=$tree}
<li>{$tree[i].page_name}</li>
{include file="children.tpl" pages="$tree[i].Children"}
{/section}
</ul>
|
But passing $tree[i].Children as the variable "pages" to children.tpl doesn't work. What do I do? |
Try using a temporary variable:
Code: |
<ul>
{section name=i loop=$tree}
<li>{$tree[i].page_name}</li>
{assign var="tmp" value="$tree[i].Children"}
{include file="children.tpl" pages="$tmp"}
{/section}
</ul>
|
|
|
Back to top |
|
andre Smarty Pro
Joined: 23 Apr 2003 Posts: 164 Location: Karlsruhe, Germany
|
Posted: Wed Jul 02, 2003 8:10 am Post subject: |
|
|
This should work:
Code: |
<ul>
{section name=i loop=$tree}
<li>{$tree[i].page_name}</li>
{include file="children.tpl" pages=$tree[i].Children}
{/section}
</ul>
|
Note that you DON'T NEED the quotes around $tree[i].Children. It is wrong to put them there!
Use quotes only for strings:
Code: |
{foo bar="this is a string"}
{foo bar=$string}
{foo bar="this is a string with an embedded `$variable`"}
|
See Smarty manual for further instructions |
|
Back to top |
|
appel Smarty Rookie
Joined: 27 May 2003 Posts: 29
|
Posted: Wed Jul 02, 2003 10:18 am Post subject: ty |
|
|
yes, thanks. this works now. |
|
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
|