|
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 |
Stream Smarty Rookie
Joined: 07 Jan 2004 Posts: 5
|
Posted: Wed Jan 07, 2004 11:47 pm Post subject: Using same template several times |
|
|
I'm pretty new to the Smarty-template and have a question.
I have a template-file that I want to reuse several places on one page, but with different assignments.
Code: | included_template.tpl:
<table><tr><td>
{$var_array}
</td></tr></table>
|
Code: | index.tpl:
Table 1:
{include file="included_template.tpl"}
Table 2:
{include file="included_template.tpl"}
|
I want $var_array to be different for those 2 tables. Is it possible to tell Smarty to assign a variable to a specific template, for instance by giving the template a name/id that you can refer to when assigning the variable?
Or is there a workaround for achieving this?
Would be thankful for any answers. |
|
Back to top |
|
messju Administrator
Joined: 16 Apr 2003 Posts: 3336 Location: Oldenburg, Germany
|
Posted: Wed Jan 07, 2004 11:50 pm Post subject: |
|
|
it's all described in the manual for {include}:
Code: | index.tpl:
Table 1:
{include file="included_template.tpl" var_array=$foo}
Table 2:
{include file="included_template.tpl" var_array=$bar}
|
|
|
Back to top |
|
Stream Smarty Rookie
Joined: 07 Jan 2004 Posts: 5
|
Posted: Thu Jan 08, 2004 12:01 am Post subject: |
|
|
messju wrote: | it's all described in the manual for {include}:
Code: | index.tpl:
Table 1:
{include file="included_template.tpl" var_array=$foo}
Table 2:
{include file="included_template.tpl" var_array=$bar}
|
|
Aha, so that's what the VAR option is used for. There was no example in the documentation about it so I didn't notice it.
Thanks for clearing this up! |
|
Back to top |
|
messju Administrator
Joined: 16 Apr 2003 Posts: 3336 Location: Oldenburg, Germany
|
Posted: Thu Jan 08, 2004 12:07 am Post subject: |
|
|
Stream wrote: | There was no example in the documentation about it so I didn't notice it. |
"Example 7-7. function include passing variables" on the page i mentionend. |
|
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
|