一个网页,比如我们要拆分成header.lbi和index.tpl和footer.lbi三个
文件,我们需要在index.tpl中引入header.lbi和footer.lbi两个
模板文件以组成完整的网页,
SmartTemplate 1.2.1以前的版本并不支持支持include的语法,但我们也可以用来<?php include('header.html');?>包含一些复用的文件,但这样的包含并不能解析其中的语法,所以只能包含一些纯静态的文件。现在这些问题已经都解决,你可直接在模板中使用include把你需要的文件包含进来.
引用:
As of version 1.2.0 templates can be included in other templates by using the INCLUDE statement.
This permit the use of subtemplating.
The syntax is the following:<!-- INCLUDE templatename.html -->
之前一直没有打到正确的方法,因为没范例,所以用
这样试:{include templatename.html}试不行,换了好几种方法也不行,正确是
复制内容到剪贴板
代码:
<!-- INCLUDE header.lbi -->以前的解决方案就是用
php把模板文件引入后assign到模板,模板里在放一个{header}类似的东东。推荐如果你的版本是smarttemplate 1 . 2 . 0 以上的就用新方法吧。