Home >CMS Tutorial >DEDECMS >How to sort the dedecms article list page by weight

How to sort the dedecms article list page by weight

尚
Original
2019-07-20 13:10:232187browse

How to sort the dedecms article list page by weight

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.

How to sort the dedecms article list page by weight

Modify the code: Add the following judgment code sorted by weight at line 727 of the file:

How to sort the dedecms article list page by weight

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.

How to sort the dedecms article list page by weight

Tag call: {dede:list orderby='weight' orderway='asc'}, so that the {dede:list} tag implements the call sorted by weight.

How to sort the dedecms article list page by weight

dede: method of sorting arclist by weight:

How to sort the dedecms article list page 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');

How to sort the dedecms article list page by weight

Insert at line 327 The following line of code:

else if($orderby == 'weight') $ordersql = " order by arc.weight asc";

How to sort the dedecms article list page by weight

tag Call: {dede:arclist orderby='weight'}, so that the {dede:arclist} tag implements the call sorted by weight.

How to sort the dedecms article list page 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!

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