织梦模板标签调用str_replace()替换函数
举个例子:
[field:sitepathfunction=str_replace("{cmspath}","http://localhost/",@me)/]
实际上是查找内容
更多精彩就在: 51免费论文网|www.jxszl.com
中指定的部分然后进行替换,上面是DEDE中的应用方法,第II个双引号实际是替换的内容,这里是http://localhost/
上面标签的作用就是查找内容中的{cmspath}并替换为http://localhost/,实际上也就是去掉.
str_replace()还有I.个参数count,是替换的次数,
语法为str_replace(find,replace,string,count)
所以我们可以引申出很多应用方法了.
比如下面的标签都可以应用
[field:info/]
[field:arcurl/]
[field:typedir/]
举个例子
[field:titlefunction=str_replace("aaa","bbb",@me)/]
[field:titlefunction=str_replace("测试","test",@me)/]
查找标题中的aaa替换成bbb,
但下面这个比较常用,主要应用于IIIII级栏目嵌套调用中
[field:typedirfunction=str_replace("{cmspath}","",@me)/]
原文链接:http://www.jxszl.com/biancheng/dedecms/76394.html