文档详情

dede织梦_高级功能function扩展-dede @me.doc

发布:2017-12-10约3.51千字共4页下载文档
文本预览下载声明
为了使用模板标记不破坏文档的可读性,dedecms不像别的模板,有时会使用直接往模板插入PHP或类似PHP的代码,以达到真正的模板与程序分离的特点。 但为了让程序有更大的扩展性,dedecms允许对标记使用 function 进行扩展,function所使用的函数可以是系统函数,也可以是自定义的函数,只是用在两个方面: 1、模板标记: 如:{dede:field name=pubdate function=GetDateTimeMk(@me)/} 这个标记实际返回的结果是执行了GetDateTimeMk函数后的结果 一般情况下,模板标记的自定义扩展函数放在: include/inc_functions.php 或 include/inc_functions.php include/inc_channel_unit_functions.php 2、采集配置字段: 如:{dede:note field=title value=[var:内容] function=test(@me)} {dede:match}title[var:内容]/title{/dede:match} {/dede:note} 这个采集节点返回的结果是执行了函数test后返回的结果 一般情况下,采集扩展的自定义扩展函数放在: include/pub_collection_functions.php 在上面例子中 @me 表示这个标记本身的原始值,如果为int或浮点型,可以不加引号,字符串则必须加引号 灵活使用扩展函数,可以做出很多随意的功能,但又不用改动系统的源码,对于采集扩展,更加是可以更灵活处理采集到的原始内容。 织梦标记允许有限的编程扩展。 当前系统时间 {dede:tagname runphp=yes}@me = date(Y);{/dede:tagname} 格式为: {dede:tagname runphp=yes} $aaa = @me; @me = 123456; {/dede:tagname} @me 表示这个标记本身的值,因此标记内编程是不能使用echo之类的语句的,只能把所有返回值传递给@me。 此外由于程序代码占用了底层模板InnerText的内容,因此需编程的标记只能使用默认的InnerText。 过滤掉HTML代码 {dede:arclist sort=hot titlelen=40 row=8} LIA title=[field:title function=html2text(@me)/] href=[field:arcurl/][field:title/]/A/LI {/dede:arclist} {dede:field name=description function=html2text(@me)/} {dede:list imgwidth=* imgheight=*} img src={dede:field name=litpic /} width=* height=* 修改 includeinc_channel_unit_functions.php 里面的 img src=.$imgsrc. width=80 align=left 可以改变缩略图尺寸 5.1以前缩略图地址是 120U10ML014147_lit.gif 5.1变成了lit_120U10ML014147.gif 把[field:picname function=str_replace(_lit,,@me)/] 换成[field:picname function=str_replace(lit_,,@me)/] function=str_replace(主页,,Html2Text(@me)) 在产品列表中,有个值经过函数处理,通常一个变量的情况下是这样的: [field:typeid function=get_linkshangpin(@me,3)/] [field:pubdate function=strftime(%m-%d,@me)/] [field:litpic function=CkLitImageView(@me,80)/] 修改 includeinc_channel_unit_functions.php 里面的 img src=.$imgsrc. width=80 align=left function=cn_substr(@me,2). 取的是这个字段左边的截取. 想从右边开始截取,用什么函数呢.. 我在用DEDE调用supersite blog 里面的博客之星图片. 它的图片地址是UID号对应的目录. 比如UID是176 可能对就的会员图片是/ 76/photo_17
显示全部
相似文档