一聚教程网:一个值得你收藏的教程网站

热门教程

smarty include_php 加载php文件

时间:2022-07-02 10:46:26 编辑:袖梨 来源:一聚教程网

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}

 

热门栏目