Dedecms5.7 has a bug in weight sorting. Let me tell you step by step how to solve the problem of invalid weight. Please refer to the details below.
The file involved is the includetaglibarclist.lib.php file:
Around line 570:
代码如下 |
复制代码 |
if ( $isweight==’y’ ) |
This line of code is simply useless, $orderWeight = list_sort_by($orderWeight, ‘weight’, ‘asc’); sorts the results.
This is problematic because before getting the $orderWeight, the statement to retrieve the document table is:
The code is as follows |
Copy code |
代码如下 |
复制代码 |
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
|
SELECT arc.*,tp.typedir,tp.typename,tp.corank,tp.isdefault,tp.defaultname,tp.namerule,
tp.namerule2,tp.ispart,tp.moresite,tp.siteurl,tp.sitepath
代码如下 |
复制代码 |
{dede:arclist orderby=’weight’ typeid=’29′ isweight=’y’
limit=’4,1′ titlelen=’100′ infolen=’100′ }
|
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
|
Obviously, when we write the tag, we write
The code is as follows |
Copy code |
{dede:arclist orderby=’weight’ typeid=’29′ isweight=’y’
代码如下 |
复制代码 |
else if($orderby ==
‘weight’) $ordersql = ” order by arc.weight asc”;
|
limit=’4,1′ titlelen=’100′ infolen=’100′ }
|
, the original intention is that the data is sorted according to weight, and the second processing program is according to
代码如下 |
复制代码 |
{dede:list pagesize='10' titlelen='50' orderby='weight'} •[field:textlink/] {/dede:list}
|
For the database retrieved by sortrank, specifying isweight=’y’ only serves to sort the retrieved data set according to weight.
So the solution is very simple: at line 330 of the program file, add a line of processing statements sorted by weight:
The code is as follows |
Copy code |
else if($orderby ==
‘weight’) $ordersql = ” order by arc.weight asc”;
代码如下 |
复制代码 |
else if($orderby=="weight") { $ordersql = " order by arc.weight $orderWay"; }
|
|
Let’s separate another one to make the list tag support weight sorting
The code is as follows |
Copy code |
{dede:list pagesize='10' titlelen='50' orderby='weight'} •[field:textlink/] {/dede:list}
|
Method:
1. Open the file arc.listview.class.php
2. Find the "else if($orderby=="lastpost") {" statement, which is probably at line 609. Press the Enter key in front of this line and insert the following statement:
The code is as follows |
Copy code |
else if($orderby=="weight") { $ordersql = " order by arc.weight $orderWay"; }
|
3. Continue to search for the "if(ereg('hot|click|lastpost',$orderby))" statement and modify it to:
The code is as follows
代码如下 |
复制代码 |
if(ereg('hot|click|weight|lastpost',$orderby))
|
|
Copy code
|
if(ereg('hot|click|weight|lastpost',$orderby))
代码如下 |
复制代码 |
{dede:arclist row='10' titlelen='50' orderby='weight'} •[field:textlink/] {/dede:arclist}
|
|
After the modification is completed, save it. If weight sorting has been used in the target, generate it and you can see that weight sorting has been installed in the document list
4. Template calling
The code is as follows
|
Copy code
{dede:arclist row='10' titlelen='50' orderby='weight'} •[field:textlink/] {/dede:arclist}
http://www.bkjia.com/PHPjc/632148.htmlwww.bkjia.comtruehttp: //www.bkjia.com/PHPjc/632148.htmlTechArticlededecms5.7 has a bug in weight sorting. Let me tell you step by step how to solve the problem of invalid weight. Please refer to the method below for details. The file involved is includetaglibarclist.l...
|
|
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