When we want to sort the articles on the list page according to the rules we specify, we often need to modify the code ourselves to achieve it. If you just want to rank a certain article or a few articles at the front, you can first call one or several articles with recommended attributes in the code, and then call the articles without recommended attributes for the remaining content. By default, Just sort by time. But what should we do when we have a large number of articles that need to be ranked in a specified position? The best way is to set it to sort by weight. Let me share with you how to sort by weight on the dedecms article list page.
dede: How to sort the list by weight:
Find the "root directory\include\arc.listview.class.php" file.
Modify the code: Add the following judgment code sorted by weight at line 727 of the file:
and then at line 727 of the file Find this code if(preg_match('/hot|click|lastpost/', $orderby)) at line 778 and add the |weight/ part.
Tag call: {dede:list orderby='weight' orderway='asc'}, so that the {dede:list} tag implements the call sorted by weight.
dede: method of sorting arclist by weight:
in lines 74 and 75 Find the following code:
//Whether arclist needs to be sorted by weight, the default is "N", if sorting is required, set it to "Y" $isweight = $ctag->GetAtt('isweight');
Change this line to:
$weight = $ctag->GetAtt('weight');
Insert at line 327 The following line of code:
else if($orderby == 'weight') $ordersql = " order by arc.weight asc";
tag Call: {dede:arclist orderby='weight'}, so that the {dede:arclist} tag implements the call sorted by weight.
For more DedeCMS related technical articles, please visit the DedeCMS Tutorial column to learn!
The above is the detailed content of How to sort the dedecms article list page by weight. For more information, please follow other related articles on the PHP Chinese website!