What should I do if dedecms’ weight sorting method is invalid?
The example in this article describes the solution to the invalid use of weight sorting by Dreamweaver dedecms. Share it with everyone for your reference. The specific method is as follows:
Recommended learning: 梦Weavercms
dedecms5.7 has a bug in weight sorting. Here I will tell you step by step how to solve the problem of invalid weight. solution.
The file involved is the includetaglibarclist.lib.php file, around line 570:
The code is as follows:
if ( $isweight=='y')
This line of code is simply useless,
The code is as follows:
$orderWeight = list_sort_by($orderWeight,'weight', 'asc');
There is a problem with sorting the results, because before getting the $orderWeight, the statement to retrieve the document table is:
The code is as follows:
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
It’s obvious, when we write the tag, we write:
The code is as follows:
{dede:arclist orderby='weight' typeid='29' isweight='y' limit='4,1' titlelen='100' infolen='100' }
The original intention is that the data is sorted according to weight, and the processing program is based on For the database retrieved by sortrank, specifying isweight='y' only serves to sort the retrieved data sets 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:
else if($orderby =='weight') $ordersql = " order by arc.weight asc";
Let’s separate another let The list tag supports weight sorting:
The code is as follows:
{dede:list pagesize='10' titlelen='50' orderby='weight'} ?[field:textlink/]<br/> {/dede:list}
Solution:
1. Open the file arc.listview.class.php
2. Find the
code as follows:
else if($orderby=="lastpost") {
statement, probably at line 609. Press the Enter key in front of this line and insert the following statement:
The code is as follows:
else if($orderby=="weight") { $ordersql = " order by arc.weight $orderWay"; }
3. Continue to search for
The code is as follows
if(ereg('hot|click|lastpost',$orderby))
statement, modify it to:
The code is as follows:
if(ereg('hot|click|weight|lastpost',$orderby))
After the modification is completed, save it. If weight sorting has been used in the target, generate it and you can see that the document list has been installed with weight sorting
4. Template call:
The code is as follows:
{dede:arclist row='10' titlelen='50' orderby='weight'} ?[field:textlink/]<br/> {/dede:arclist}
The above is the detailed content of What should I do if the weight sorting method used by Dedecms does not work?. For more information, please follow other related articles on the PHP Chinese website!