Smarty Forum Index Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon.

Using same template several times

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> General
View previous topic :: View next topic  
Author Message
Stream
Smarty Rookie


Joined: 07 Jan 2004
Posts: 5

PostPosted: Wed Jan 07, 2004 11:47 pm    Post subject: Using same template several times Reply with quote

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
View user's profile Send private message
messju
Administrator


Joined: 16 Apr 2003
Posts: 3336
Location: Oldenburg, Germany

PostPosted: Wed Jan 07, 2004 11:50 pm    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail Visit poster's website
Stream
Smarty Rookie


Joined: 07 Jan 2004
Posts: 5

PostPosted: Thu Jan 08, 2004 12:01 am    Post subject: Reply with quote

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
View user's profile Send private message
messju
Administrator


Joined: 16 Apr 2003
Posts: 3336
Location: Oldenburg, Germany

PostPosted: Thu Jan 08, 2004 12:07 am    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail Visit poster's website
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> General All times are GMT
Page 1 of 1

 
Jump to:  
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
Protected by Anti-Spam ACP