Chinaunix
标题:
Smarty模板的使用:include_php
[打印本页]
作者:
dongyue91
时间:
2009-10-29 16:32
标题:
Smarty模板的使用:include_php
[CODE:]
[color="#ff6600"]
require_once('./Path.Setting.php');
require_once('./Setting.Inc.php');
require_once(QuiZ_Path.'../Classes/FileName_Set.php');
$link = new ExecSQL(); #SQL操作
$menu = new Menu_Class(); #菜单生成
$link -> SetSQL("Select * From ".Base::$Menu_Left." order by path");
$menu -> Set_Array($link -> Query_array());
$Smarty -> assign('menu_select',$menu -> Menu_Select());
$Smarty -> display('add.tpl');
[color="#ff0000"]
?>
[CODE:]
[color="#ff6600"]
#add.tpl
?
[color="#ff0000"]
{include_php file="./Menu.php"}
[color="#ff0000"]
?>
[CODE:]
[color="#ff6600"]
require_once('./Path.Setting.php'
);
require_once('./Setting.Inc.php'
);
require_once(QuiZ_Path.'../Classes/FileName_Set.php'
);
$link = new ExecSQL
();
$menu = new Menu_Class
();
$link -> SetSQL("Select * From ".Base::$Menu_Left." order by path"
);
$menu -> Set_Array($link -> Query_array
());
$abc = $menu -> Menu_Output();
$this -> assign('menu',$abc
);
$this -> display('Menu.tpl');
[color="#ff0000"]
?>
[CODE:]
[color="#ff6600"]
[color="#000000"]
{$menu}
[color="#ff0000"]
?>
{include_php file="./Menu.php"} SMARTY中include_php的使用
add.php中按正常使用SMARTY模板add.tpl → 模板中使用{include_php file="./Menu.php"}
Menu.php中使用$this来解释执行Menu.tpl
这样就可以正常使用include_php来包含文件了.
本文来自ChinaUnix博客,如果查看原文请点:
http://blog.chinaunix.net/u3/105169/showart_2082221.html
欢迎光临 Chinaunix (http://bbs.chinaunix.net/)
Powered by Discuz! X3.2