dedecms织梦常用调用代码
我们在给公司做网站的时候,老板们可不是什么代码都懂的人,一般的老板只是会喝酒吃肉的大胖子(咳咳),顺便给大家贴一些公司非常有用的代码
可以直接调用栏目说明里的内容:
{dede:sql sql='Select content from dede_arctype where id=15' titlelen=60} [field:content function=cn_substr(@me,500)/] {/dede:sql}
列表页调用当前栏目的代码
{dede:field name='typename'/}
倒序排列:orderway='asc'
正常排列:orderway='desc'
文章摘要描述
1.[field:info /]
2.[field:description /]
3.[field:info function=”cn_substr(@me,字符数)”/]
4.[field:description function=”cn_substr(@me,字符数)”/]
第1、2种方法是直接调用文章摘要在调用的字数问题上当使用[field:info /]时可以在{dede:arclist infolen=’ ‘ }{/dede:arclist}中设置调用摘要的字符数?最高可设置为系统设置的250,如果使用[field:description /]则直接使用后台设置的摘要字符上限。显然这两种方式都很被动灵活性太差。 第3、4种方法通过function函数实现了对文章摘要显示字符的灵活调整。当然在没有修改文章摘要内容字符上限时这4个方法的差异并不大。但是下面我们来说如何修改这一上限值就可以体现出[field:description function=”cn_substr(@me,字符数)”/]这一方式的重要性。
文章图片地址调用代码:[field:litpic/]
例: <a title="[field:title /]" href="[field:arcurl /]"><img alt="[field:title /]" src="[field:litpic/]" width="200" height="200"><span>
文章分页调用
<div class=”pages clear”>{dede:pagelist listitem=”index,end,pre,next,pageno” listsize=”5″/} </div>
pages clear 可以设置样式
我们都知道织梦Dedecms的默认排列顺序都是“pubdate”是倒序排列的,那么如何才能让文章列表倒序排列呢?
经过研究本人发现有两种比较简单的方法:
第一种方法:
第一步、打开编辑plus/feedback.php 2. 找到第76行,将desc替换为asc。然后保存退出,重新生成静态后,打开浏览器,随便打开一片文章,查看评论页的排序是不是都成了倒序了!
第二种方法:
用dedecms的文章调用标签把orderway=’pubdate’修改成orderway=’asc’,这种方法可根据不同栏目的需要来进行修改。
两种方法比较而言,第二种更灵活。
文章内容段落首行缩进
找到\templets\default\style\page.css
加入以下代码:.viewbox .content p{
text-indent: 24px;
}
首页调用商品价格
{dede:arclist addfields=’trueprice,price’ channelid=’6′ typeid=1 row=6 titlelen=100 orderby=’pubdate’} 优惠价:[field:trueprice/]br / 市场价:[field:price/] {/dede:arclist}
{dede:arclist addfields=’trueprice,price’ channelid=’6′ typeid=1 row=6 titlelen=100 orderby=’pubdate’}
优惠价:[field:trueprice/]<br />
市场价:[field:price/]
{/dede:arclist}
</script>