PHP学会网 php培训网 PHP暑期培训 PHP寒假培训 PHP假期培训 » PHP中高级 » smarty如何包含另一个smarty文件?
本页主题: smarty如何包含另一个smarty文件? 打印 | 加为IE收藏 | 收藏主题 | 上一主题 | 下一主题

芽雨



该用户目前不在线
级别: 新手上路
精华: 0
发帖: 3
威望: 1 点
金钱: 10 PYMB
贡献值: 0 点
在线时间:0(小时)
注册时间:2005-11-06
最后登录:2006-10-05

smarty如何包含另一个smarty文件?


顶端 Posted: 2005-11-06 21:36 | [楼 主]
芽雨



该用户目前不在线
级别: 新手上路
精华: 0
发帖: 3
威望: 1 点
金钱: 10 PYMB
贡献值: 0 点
在线时间:0(小时)
注册时间:2005-11-06
最后登录:2006-10-05

smarty如何包含另一个smarty文件?


偶在.tpl文件中这样:<{include file="blog_link.tpl"}>

这样只能输出被包含文件的html部分

里面的变量无法输出

应该如何?

注:

偶两个php文件都有:

PHP代码:--------------------------------------------------------------------------------
require_once ("class/Smarty.class.php");

$smarty = new Smarty();
$smarty->template_dir = "./templates";//设置模板目录
$smarty->compile_dir = "./templates_c"; //设置编译目录
$smarty->config_dir = "./configs";
$smarty->cache_dir = "./cache";
$smarty->cache_lifetime = 60 * 60 * 24; //设置缓存时间
$smarty->caching = false; //调试时设为false,发布时用true

//----------------------------------------------------
//左右边界符,默认为{},但实际应用当中容易与JavaScript
//相冲突,所以建议设成<{}>或其它。
//----------------------------------------------------
$smarty->left_delimiter = "<{"; //设置左边界符
$smarty->right_delimiter = "}>"; //设置右边界符

require("xtsz/include.php");
require("xtsz/inc.php");
require("xtsz/total.php");



$smarty->assign(……);

$smarty->display(……);
顶端 Posted: 2005-11-06 21:36 | 1 楼
游子云



该用户目前不在线
级别: 管理员
精华: 3
发帖: 246
威望: 205 点
金钱: 2066 PYMB
贡献值: 0 点
在线时间:38(小时)
注册时间:2005-10-27
最后登录:2008-08-19


在smarty中,因路径的的原因,不能解很好的解析引入php的解析模板;一般引入纯php不会出错!

例如{include_php file="/path/to/load_nav.php"}

[[i] Last edited by 游子云 on 2005-11-6 at 09:42 PM [/i]]
顶端 Posted: 2005-11-06 21:39 | 2 楼
芽雨



该用户目前不在线
级别: 新手上路
精华: 0
发帖: 3
威望: 1 点
金钱: 10 PYMB
贡献值: 0 点
在线时间:0(小时)
注册时间:2005-11-06
最后登录:2006-10-05


<{include_php file="../article_index.php"}>

偶在tpl中用上面的,结果连html部分的都不输出了
顶端 Posted: 2005-11-06 21:48 | 3 楼
Tina



该用户目前不在线
级别: 新手上路
精华: 0
发帖: 37
威望: -2 点
金钱: -20 PYMB
贡献值: 0 点
在线时间:0(小时)
注册时间:2005-10-24
最后登录:1970-01-01


你这样需要在你的tpl中包含要包含的tpl

然后在php中包含对应的php文件!
顶端 Posted: 2005-11-12 19:20 | 4 楼
PHP学会网 php培训网 PHP暑期培训 PHP寒假培训 PHP假期培训 » PHP中高级

现在时间:09-08 06:28 Copyright © 2006 phpwhy.com 版权所有
浙ICP备05060669号

点击这里给我发消息关于我们 - 合作联系