广州传奇网络

地址:广州市天河区东圃大马路富华楼C座

电话:13808825895

邮箱:gz020wbs@163.com

QQ:1564443073

网址:http://www.020wbs.com/

首页 > 二次开发Ecshop二次开发 > Ecshop模板之Smarty运用(三)

二次开发Ecshop二次开发

二次开发Ecshop二次开发

Ecshop模板之Smarty运用(三)

五. 循环

  在Smarty里使用循环遍历数组的方法是section,如何赋值遍历都是在模板中解决,php源文件中只要一个assign就能解决问题。

  示例:
{* this examplewill print out all the values of the $custid array *}
{sectionname=customer loop=$custid}
id: {$custid[customer]}<br>
{/section}
OUTPUT:
id: 1000<br>id: 1001<br>id: 1002<br>

六. 常见问题

  Smarty将所有大括号{}里的东西都视为自己的逻辑程序,于是我们在网页中想插入javascript函数就需要literal的帮忙了,literal的功能就是忽略大括号{}。

  示例:
{literal}
<script language=javascript>
function isblank(field) {
if (field.value == '') { return false;
}else{
document.loginform.submit();
return true;
}
}
</script>
{/literal}

1.Smarty官方站点: http://smarty.php.net www.smarty.net
2.Smarty入门: http://www.php5.idv.tw/documents/smarty/smarty20040209.htm