- 论坛徽章:
- 0
|
今天碰到SmartTemplate 模板的嵌套问题
主模板: page.htm
{page_title}
Page Header Bar.
{body_text}
Page Footer.
要填充的模板: box.htm
This is a content box.
Content: {box_text}
PHP CODE: box.php
assign('text','This is a Test Text!');
$body_text = $tpls->result();
?>
PHP CODE: test.php
assign('page_title','Text Page Test!');
$tpl->assign('body', $body_text);
$tpl->output();
?>
结果发现box.php文件无法解析模板中的{text}变量。
test.php文件无法解析{page_title}和{body_text}变量。
大概看了一下class.smarttemplate.php文件。
smarttemplate 的 result()方法是把缓冲区的内容取出来。
按理来说 $tpl 和 $tpls 两个对象的数据在不同的内存空间。
$tpls->result()把缓冲区的内容清空后怎么能影响$tpl对象呢?
另外很不理解 smarttemplate 的 output() 方法中的 $_top 参数。
而且还用了 global 声明。
smarttemplate 的模板文件仅仅限制于一个模板文件?
能不能实现PHPLIB中的template 的 set_file() 那样的功能?
一个模板对象能处理多个模板文件。而且可以自由的方便的对其中的某个模板文件的内容
嵌套到其他模板文件的某个变量中呢?
得发到论坛请高手才行了!
本文来自ChinaUnix博客,如果查看原文请点:http://blog.chinaunix.net/u/13344/showart_230675.html |
|