模板引擎二
要遍历一个目录下的子目录,那么就可以这样写了。
{$about sql="Select * From [download_fl] where parentid in (($test)) order by id desc"} <li>{about.title}</li> {/$about}
在ASP中写入:tpl.d("test")="1,2,3",具体的大家可以用一个函数来生成子节点,然后就可以调用了。这样的写法可以遍历所有的子目录。其中模板中的
(($test))两个括号是非常的关键的,如果只是一个括号的话会被程序过滤。
有兴趣的可以试一下,本人测试没什么问题。
要生成html静态文件的可以这样用:tpl.create =server.mappath(filepath),filepath是生成文件的文件路径+文件名。
不同表名的话还可以这样写:
{$about sql="Select * From ($table) order by id desc"}
ASP中这样写:tpl.d("table) = 表名,程序会自动将($table)替换你需要的表名
为了使前台开发更加直观的话可以这样写:<!--{$about sql="Select * From ($table) order by id desc"}-->,效果是一样的。
IF的用法:
<ul> {$news tablename="news" tableid="newsid" order="0" where="" pagesize="10" } <li><ahref="news.asp?id={news.newsid}"> {if {news.newsid}=6}<fontcolor="red"> {news.newsid}、{news.topic} {news.nfrom}</font> {else} {news.newsid}、{news.topic} {news.nfrom} {/if} </a></li> {/$news} </ul>
浙公网安备 33010602011771号