【www.gdgbn.com--smarty模板】
Example 7-21. function {include_php}
The load_nav.php file:
// load in variables from a mysql db and assign them to the template
require_once("database.class.php");
$db = new Db();
$db->query("select url, name from navigation order by name");
$this->assign("navigation", $db->getRows());
?>
在模板中我们如下设置
{* absolute path, or relative to $trusted_dir *}
{include_php file="/path/to/load_nav.php"}
{foreach item="nav" from=$navigation}
{$nav.name}
{/foreach}