Home > php教程 > php手册 > 织梦cms利用weight排序无效的解决方法

织梦cms利用weight排序无效的解决方法

WBOY
Release: 2016-06-13 09:56:52
Original
960 people have browsed it

dedecms5.7针对weight排序是有bug的,下面我来一步步告诉大家如何解决weight无效的解决办法,具体请参考下面。

涉及的文件是includetaglibarclist.lib.php文件:

第570行左右:

 代码如下 复制代码
if ( $isweight==’y’ )

这一行代码简直是废柴,$orderWeight = list_sort_by($orderWeight, ‘weight’, ‘asc’);  对结果进行排序。

这个是有问题的,因为在得到这个$orderWeight之前,检索文档表的语句为:

 代码如下 复制代码

SELECT arc.*,tp.typedir,tp.typename,tp.corank,tp.isdefault,tp.defaultname,tp.namerule,

tp.namerule2,tp.ispart,tp.moresite,tp.siteurl,tp.sitepath
FROM `dede_archives` arc LEFT JOIN `dede_arctype` tp ON arc.typeid=tp.id WHERE arc.typeid IN (29) AND

arc.arcrank > -1 ORDER BY arc.sortrank DESC

很明显了吧,我们在写标签的时候,写的是

 代码如下 复制代码

{dede:arclist orderby=’weight’ typeid=’29′ isweight=’y’

limit=’4,1′ titlelen=’100′ infolen=’100′ }

,本意是数据按照weight进行排序,二处理程序是按照

sortrank 检索的数据库,指定 isweight=’y’ 仅仅是起到了将检索出的数据集再根据weight排序。

 
所以处理办法非常简单:在该程序文件330行处,增加一行按照weight排序的处理语句:

 代码如下 复制代码

else if($orderby ==

‘weight’) $ordersql = ” order by arc.weight asc”;

我们再分离一个让list标签支持weight排序

 代码如下 复制代码

{dede:list pagesize='10' titlelen='50' orderby='weight'} •[field:textlink/]
{/dede:list}

办法:

1、打开文件arc.listview.class.php

2、查找“else if($orderby=="lastpost") {” 语句,大概在609行,在此行前面按下回车健,插入如下语句:

 代码如下 复制代码

else if($orderby=="weight") {     $ordersql = " order by arc.weight $orderWay"; }

3、继续查找“if(ereg('hot|click|lastpost',$orderby))”语句,修改为:

 代码如下 复制代码

if(ereg('hot|click|weight|lastpost',$orderby))

修改完成后,保存,如果目标里面已经使用了weight排序,生成一下,就可以看到,文档列表已经安装weight排序

4、模板调用

 代码如下 复制代码

{dede:arclist row='10' titlelen='50' orderby='weight'} •[field:textlink/]
{/dede:arclist}

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template