列表页field:description/field:info设置调用字数长度,实现方案为使用cn_substr()函数。
在Dedecms中,在列表页调用文章摘要的方法有:
- [field:info/]
- [field:description/]
- [field:info function=”cn_substr(@me,120)”/]
- [field:description function=’cn_substr(@me,170)’/]
cn_substr()函数使用方法
函数名:cn_substr
适用版本:(>=DedeCMS 2,DedeCMS 3,DedeCMS 4,DedeCMS 5)
功能:截取中文字符串
参数:
- $str=” 需要截取的字符串
- $slen=” 需要截取的长度,单字节截取模式,一个中文占用2个字节
- $startdd=0 截取开始位置标记处,默认为0从头开始
返回值: 返回截取后的字符串,错误返回空字符串
例:
[field:description function='cn_substr(@me,170)'/]
默认description内容中按字符数从前往后截取170个。
此函数适用dedecms中所有调取字符的标签!
评论前必须 ☞☞ 登录/注册 !