Re: [SMARTY] Is it possible to retrieve a value from a template
| From: | Jason Jones | Date: | Sat, 08 Feb 2003 05:45:46 +0000 |
| Subject: | Re: [SMARTY] Is it possible to retrieve a value from a template | ||
| References: | 1 | Groups: | php.smarty.general |
| Request: | Send a blank email to php-smarty-general+get-7582@lists.php.net to get a copy of this message | ||
I think you're missing the whole beauty of the Smarty system. Smarty provides a clean abstraction between your PHP code and a display mechanism... in other words... let PHP do all the grunt work in preparing the data (and getting info/data from an SQL DB), assign all the relevant variables to the Smarty template, and then show the template... something like this, for example:
script.php:
$count = $DB->getOne("select foo from bar");
$smarty = new Smarty;
$smarty->assign("count", $count);
$smarty->display("thing.tpl");
thing.tpl
<html><body>The count was {$count}</body></html>
Maybe that's not what you were getting at. But besides that, the templates can be programmed with conditional logic to display the correct block and utilize the appropriate variables. HTH...
-Jason Jones
LPA wrote:
Hi, I'm new with Smarty and here is my problem. I have pages wich can contain (or not) blocs. These blocs are others templates. Each blocs need some sql commands. I dont want to execute all sql commands before display each page... for example, i'd like to do : $page = new Smarty; if ($page->Is_Bloc("index.tpl","bloc1")) { $sql="select ..... .... $page->Assign(..) } Thanx for your help Laurent