smarty 流程控制总结

来源:互联网 发布:高晓松和罗振宇 知乎 编辑:程序博客网 时间:2024/05/22 12:03
smarty 流程控制总结
1、文件导入
<{include file="admin/pagefooter.htm"}>
2、foreach 应用
<{foreach from=$links item=link}>
 <li><a href="<{$link.href}>"><{$link.text}></a></li>
<{/foreach}>
3、if else 应用
<{if $msg_type==0}>
<img src="images/information.gif" width="32" height="32" border="0" alt="information" />
<{elseif $msg_type eq 1}>
<img src="images/warning.gif" width="32" height="32" border="0" alt="warning" />
<{else}>
<img src="images/confirm.gif" width="32" height="32" border="0" alt="confirm" />
<{/if}>
4、注释
<!-- saved from url=(0053)http://localhost/sqecshop/admin/category.php?act=list -->
5、直接显示
<{$alluser}>
6、section应用
<{section name=nloop loop=$news_data}>
  <tr align="center" bgcolor="<{cycle values="#f1f2f3,#ffffff"}>">
    <td><a href="show<{$news_data[nloop].id}>.htm"><{$news_data[nloop].title}></a></td>
    <td><{$news_data[nloop].add_date|date_format:"%Y-%m-%d"}></td>
    <td><{$news_data[nloop].hits}></td>
  </tr>
<{sectionelse}>
<tr><td colspan="3">对不起,没有任何新闻输入!</td></tr>
<{/section}>
原创粉丝点击