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

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

Jun 13, 2016 am 09:56 AM
cmsusesortmethodinvalidofdream weavingsolve

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}

Statement
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

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
3 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
3 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
WWE 2K25: How To Unlock Everything In MyRise
1 months agoBy尊渡假赌尊渡假赌尊渡假赌

Hot Tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Safe Exam Browser

Safe Exam Browser

Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.

MantisBT

MantisBT

Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

SecLists

SecLists

SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

ZendStudio 13.5.1 Mac

ZendStudio 13.5.1 Mac

Powerful PHP integrated development environment