smarty include_php 加载php文件
smarty include_php
Example 7-21. function {include_php}
The load_nav.php file:
<?php
//load in variables from a php 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} <a href="{$nav.url}">{$nav.name}</a><br />{/foreach}
本文地址:http://www.phprm.com/frame/smarty_include_php.html
转载随意,但请附上文章地址:-)