RE: [SMARTY] assign
| From: | Josh Johnson | Date: | Sun, 29 Sep 2002 01:40:17 +0000 |
| Subject: | RE: [SMARTY] assign | ||
| References: | 1 | Groups: | php.smarty.general |
| Request: | Send a blank email to php-smarty-general+get-6042@lists.php.net to get a copy of this message | ||
When you include the second template, you can pass variables to it (I
think this is a feature of a very recent version of smarty, so check the
docs to be sure it'll work for your installation)...
Like:
{include file=mypage.tpl title="test"}
title will be available inside of mypage.tpl as a normal template
variable.
So you could get the info you need (from the database or whatever),
assign it to the main template (index.tpl) and then pass it when you
include the second template.
-- Josh
-----Original Message-----
From: Peter J. Pieczora [mailto:pjpieczora@sympatico.ca]
Sent: Friday, September 27, 2002 11:30 PM
To: smarty-general@lists.php.net
Subject: [SMARTY] assign
Hi,
It's really a newbie question, so if my lingo isn't quite right please
forgive
me.
How can I assign variables to the template called from index.tpl?
In my case when I do $t->display('mypage.tpl'); it all works fine, but
in case
when I call the page from $t->display('index.tpl'); and do
$t->assign("Content", "$template"); it doesn't.
Providing mypage.tpl needs to access db to pull data out to display.
$query = "SELECT * FROM $table WHERE id='$id'";
$result = mysql_query($query1);
while ($data = mysql_fetch_array ($result))
{
$c_length .= $data1[c_length];
$c_dates .= $data1[c_dates];
......
}
$t->assign("c_length", "$c_length");
$t->assign("c_dates", "$c_dates");
Peter
--
Smarty General Mailing List (http://smarty.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php