DEDECMS5.7 首页和栏目页调用文章按权重排序
dedecms 5.7版本已增加按权重排序功能:
【arclist】标签增加按权重排序,在后台管理DEDE里找到以下目录\include\taglib中的arclist.lib.php文件并打开
大约在74 、75行找到:
// arclist是否需要weight排序,默认为”N”,如果需要排序则设置为”Y”
$isweight = $ctag->GetAtt(‘isweight’);
从这里可以看出,新版本增加了一个布尔变量,直接在模板标签里加入isweight='Y' 即可!
首页中调用:
首页中采用 {dede:arclist }标签,调用方法如下
{dede:arclist typeid=50 isweight='Y' }
栏目页调用:
栏目页采用{dede:list}标签,调用方法如下
{dede:list orderby='weight' orderway='asc'}
参考来源
http://blog.sina.com.cn/s/blog_6797a67001015ae5.html
一、dedecms v5.6列表页标签{dede:list增加按权重排序标签
dedecms v5.6版本已经中已经添加权重字段,并且在{dede:arclist标签中默认可以使用。但在列表页的标签 {dede:list中是还是无法按权重实现排序。其实解决方法很简单,下面给出方法:
1、在织梦系统中找到以下目录\include\taglib中的arclist.lib.php文件并打开,因为我们要从其中拷贝代码;
2、在上面打开的文件中搜索“文档排序的方式”,可以找到如下代码
else if($orderby == 'weight') $ordersql = " order by arc.weight asc";//如果没有特定设置排序则按照权重先排序
3、拷贝这段代码,然后打开\include\目录中的arc.listview.class.php文件,搜索“排序方式”,然后在
else if($orderby=="lastpost") {
$ordersql = " order by arc.lastpost $orderWay";
} 这段代码和
else {
$ordersql=" order by arc.sortrank $orderWay";
}
这段代码中间粘贴上刚才复制的代码。
4、向下找到if(ereg('hot|click|lastpost',$orderby))修改成if(ereg('hot|click|lastpost|weight',$orderby)) ,保存文件。
这个时候在列表页里就可以使用{dede:list pagesize='5' orderby='weight'} 进行排序了。
二、DEDE 5.7 首页【arclist】增加按权重排序
1、在织梦系统中找到以下目录\include\taglib中的arclist.lib.php文件并打开
大约在74 、75行找到:
// arclist是否需要weight排序,默认为"N",如果需要排序则设置为"Y"
$isweight = $ctag->GetAtt('isweight');
把这行修改为:
$weight = $ctag->GetAtt('weight');
大约在327行找到
//文档排序的方式
$ordersql = '';
if($orderby=='hot' || $orderby=='click') $ordersql = " ORDER BY arc.click $orderWay";
else if($orderby == 'sortrank' || $orderby=='pubdate') $ordersql = " ORDER BY arc.sortrank $orderWay";
else if($orderby == 'id') $ordersql = " ORDER BY arc.id $orderWay";
else if($orderby == 'near') $ordersql = " ORDER BY ABS(arc.id - ".$arcid.")";
else if($orderby == 'lastpost') $ordersql = " ORDER BY arc.lastpost $orderWay";
else if($orderby == 'scores') $ordersql = " ORDER BY arc.scores $orderWay";
else if($orderby == 'rand') $ordersql = " ORDER BY rand()";
else $ordersql = " ORDER BY arc.sortrank $orderWay";
修改为:
//文档排序的方式
$ordersql = '';
if($orderby=='hot' || $orderby=='click') $ordersql = " ORDER BY arc.click $orderWay";
else if($orderby == 'sortrank' || $orderby=='pubdate') $ordersql = " ORDER BY arc.sortrank $orderWay";
else if($orderby == 'id') $ordersql = " ORDER BY arc.id $orderWay";
else if($orderby == 'near') $ordersql = " ORDER BY ABS(arc.id - ".$arcid.")";
else if($orderby == 'lastpost') $ordersql = " ORDER BY arc.lastpost $orderWay";
else if($orderby == 'scores') $ordersql = " ORDER BY arc.scores $orderWay";
else if($orderby == 'rand') $ordersql = " ORDER BY rand()";
else if($orderby == 'weight') $ordersql = " order by arc.weight asc";//如果没有特定设置排序则按照权重先排序
else $ordersql = " ORDER BY arc.sortrank $orderWay";
OK 现在把这个文档保存了 我们就可以在首页使用 orderby='weight' 进行排序了。
DEDECMS5.7 首页和栏目页调用文章按权重排序的更多相关文章
- 织梦首页、列表页调用文章body内容的两种方法
http://blog.csdn.net/langyu1021/article/details/52261411 关于首页.列表页调用文章body内容的两种方法,具体方法如下: 第一种方法: {ded ...
- dedecms织梦判断当前页面是首页、栏目页还是文章页
根据全局变量$GLOBALS['_sys_globals']['curfile']的值来判断. 首页parview:列表页listview:文章页archives 应用示例: {dede:php}if ...
- DedeCms 首页、列表页调用文章body内容的方法
[第一种方法] arclist标签使用如下: {dede:arclist row='1' typeid='1' addfields='body' idlist='1' channelid='1'} [ ...
- dede 首页或列表页调用文章内容页body内容
在使用dede过程,有的朋友会调调出文章的列表的内容出来,怎么调呢?当然是用dede的传参的数据查询语句了,方法如下: {dede:arclist flag=h typeid=2 row=1 titl ...
- dede频道页实现三级栏目嵌套调用文章
dede频道页实现三级栏目嵌套调用文章: //支持arclist标签开始--> $typeid = $row['id']; if((class_exists('PartView'))) { ...
- 织梦dedecms首页、列表页、文章页文章点击浏览次数实时调用方法
首先呢,先在根目录 /plus 目录下找到count.php 复制一份然后命名为viewclick.php(你也可以命名为你容易理解的名字)用编辑器将viewclick.php打开然后删除以下几行代 ...
- dede织梦栏目页和文章页中获取当前栏目名称方法
一般情况下,在dede织梦系统中列表页.栏目页和文章页中获取当前所在栏目名称只需要代码:{dede:type}[field:typename]{/dede:type}即可,不需要定义ID,默认的就是当 ...
- DEDECMS首页和列表页调用单个图片集里的多张图片
/**DEDECMS首页和列表页调用单个图片集里的多张图片 function Getimg($aid,$imgwith=110,$imgheight=110,$num=0) { global $dsq ...
- 更新上篇文章 调用三级目录文章内容 dede频道页实现三级栏目嵌套调用文章
原文:http://www.wuaie.com/?p=66 源码改写 $typeid = $row['id']; if((class_exists('PartView'))) { $pv = new ...
随机推荐
- Fast Report Data Filter
使用Data Filter两种方式:一种是 直接在Filter 属性里写表达式 ,另外一种就是在beforePrint 事件里写方法. 今天开发时遇到了一个Filter的问题,不知道是不是fast r ...
- 获取动态SQL查询语句返回值(sp_executesql)
在写存储过程时经常会遇到需要拼接SQL语句的情况,一般情况下仅仅是为了执行拼接后的语句使用exec(@sql)即可. 而今天的一个存储过程却需要获取动态SQL的查询结果. 需求描述:在某表中根据Id值 ...
- android调试bug集锦 onActivityResult立即返回,并且被CANCEL
症状: 在使用startActivityForResult调用照相机或者选择图片的时候,总是onActivityResult立马返回,resultCode=0 CANCEL. startActivit ...
- nRF52系列——Get started
Install Jlink Install MDK 这里的使用的是MDK 5.14 Install SDK https://developer.nordicsemi.com/nRF52_SDK/ 这里 ...
- PyCharm如何设置显示行号?
File->setting->Editor->General->Appearance,勾选Show line numbers
- Java操作Oracle数据库以及调用存储过程
操作Oracle数据库 publicclass DBConnection { //jdbc:oracle:thin:@localhost:1521:orcl publicstaticf ...
- Contest20140705 testA 二分
testA 输入文件: testA.in 输出文件testA.out 时限2000ms 问题描述: 有一个城市拥有N个节点,被M条有权无向路径连接.现在你要在一个地方(可以在路径上当然也可以在节点上) ...
- [BZOJ 3564] [SHOI2014] 信号增幅仪 【最小圆覆盖】
题目链接:BZOJ - 3564 题目分析 求最小椭圆覆盖,题目给定了椭圆的长轴与 x 轴正方向的夹角,给定了椭圆长轴与短轴的比值. 那么先将所有点旋转一个角度,使椭圆长轴与 x 轴平行,再将所有点的 ...
- CAVLC
在H.264标准中,CAVLC(Context-based Adaptive Variable Length Coding)被用于亮度和色度残差数据编码.在标准的码流结构中,CAVLC编码方式描述为c ...
- Android中关于List与Json转化问题
比如 List<String>list=new ArrayList<String>(); list.add("test1"); list.add(" ...