smarty中的这个数组如果理解呀,该如何解决

WBOY
Release: 2016-06-13 13:35:40
Original
819 people have browsed it

smarty中的这个数组如果理解呀
$arr|api:'cases':'getInfoList':"where pass=1^ ORDER BY topflag DESC,submit_date DESC^0^8^id,title,thumbnail,bedeck^^0"

在BIweb中的这数组怎么理解呀??

------解决方案--------------------
给lz找个手册上的例子 :{$articleTitle|truncate:30:"":true} 意思是把$articleTitle变量传入truncate方法中,附带三个参数30、""、true,然后返回截取后的结果
如果能看懂上面的例子,lz就应该很清楚了,api是自定义函数,后接三个用 ':' 隔开参数
'|'符号是类似于管道的功能,将$arr传给api函数,返回经过处理的结果
参考下面的文章:
http://www.189works.com/article-39919-1.html
------解决方案--------------------
变量调节器用于变量,自定义函数和字符串。使用‘|’符号和调节器名称应用调节器。变量调节器由赋予的参数值决定其行为。参数由‘:’符号分开。

Smarty模板引擎中的自定义函数放在插件目录(plugins)下,内建函数写在smarty本身的语法里面。自定义函数可以任意修改,任意添加,内建函数则不然。

我们可以在plugins目录下自定义函数文件,但必须严格按照smarty的函数命名规范,以便我们在调用自定义函数的时候,smarty才能够在plugins下找到。

接下来,我们将定义两个自定义函数:
函数stredit用于对字符串的大小写转换操作
函数jiequ用于对字符串进行截取操作

 命名规范:
变量调节器文件名必需以modifier开头,后面接上自定义函数名:如modifier.stredit.php,modifier.jiequ.php
变量调节器函数名的命名必需以smarty_modifier_开头,后接上自定义函数名:如smarty_modifier_stredit()、smarty_modifier_jiequ()

自定义字符串操作函数

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!