Nov122012
smarty调用全局变量
smarty中调用全局变量的方法如下:
smarty变量的运用:我们都知道smarty是一种经常与php联合起来运用的一种模板应用smarty变量的值,都是通过assign() 该方法来进行赋值的,smarty提供了一种在模块文件里面获取php define的变量,代码如下:
在php文件里面,定义了:
define('MYDATA','我是全局定义');
在模板文件里面,应该这样来获取:
{$smarty.const.MYDATA}
通过这样的...阅读全文
抢沙发
Jul072012
smarty 官网地址
用php的人都应该知道smarty是一个著名的php模板引擎,我大部分时候也使用smarty作为模板引擎。
我觉得用php最大的好处就是有类似这样的插件类的应用,大大的提高我们的开发速度。
网站开发之.net与php比较
在我这些年使用.net和php的经验来看,在有成熟框架下,php的开发速度要比.net要快。而且网站中开发中著名的MVC架构,php的mvc要比.net的MVC好用很多,做网站我还是喜欢用php多...阅读全文
Apr182012
smarty 截取字符串函数 truncate
smarty truncate 如何截取字符串?
请看下面的例子:
index.tpl:
{$articleTitle}
{$articleTitle|truncate}
{$articleTitle|truncate:30}
{$articleTitle|truncate:30:""}
{$articleTitle|truncate:30:"---"}
{$articleTitle|truncate:30:"":true}
{$articleTitle|truncate:30:"...":true}
輸出結果:
Two Sisters Reunite after Eighteen Years at Checkout Counter.
T...阅读全文
Mar182012
smarty中foreach索引
使用smarty模板时偶尔会用到索引,因用的时候不是很多,很容易忘记,在此做个记号。
{foreach name=top from=$top_goods item=goods}
{$smarty.foreach.top.iteration}
<a href="/{$goods.url}" title="{$goods.name|escape:html}">
<img src="/{$goods.goods_img}" alt="{$goods.name|escape:html}"/></a>
{/foreach}
这里 $smarty.foreach.top.itera...阅读全文