DEDECMS5.7 Home and column page call articles by weight sort

Source: Internet
Author: User
Tags ereg

The dedecms 5.7 version has been added by the weight sorting feature:

"Arclist" label added by weight, in the background management Dede found in the following directory \include\taglib arclist.lib.php file and open

Found at approximately 74, 75 rows:

Arclist If weight sort is required, default is "N" and set to "Y" if sorting is required

$isweight = $ctag->getatt (' isweight ');

As can be seen from here, the new version added a Boolean variable, directly in the template tag to add isweight= ' Y ' Can!

The first page calls:

The {dede:arclist} tag is used in the home page and is called as follows

{dede:arclist typeid=50 isweight= ' Y '}

Column Page Call:

The column page takes the {dede:list} tag and calls the method as follows

{dede:list orderby= ' weight ' orderway= ' ASC '}


First, Dedecms v5.6 list page label {dede:list increase by weight sort label

The Dedecms v5.6 version already has the weight field added and is available by default in the {dede:arclist tab. However, it is still not possible to sort by weight in the label {Dede:list of the list page. In fact, the solution is very simple, the following methods are given:

1, in the dream system to find the following directory \include\taglib in the arclist.lib.php file and open, because we want to copy code from it;

2, in the above open file search "How to sort Documents", you can find the following code

else if ($orderby = = ' weight ') $ordersql = "ORDER by arc.weight ASC";//If no specific setting is sorted by weight first

3. Copy this code, then open the arc.listview.class.php file in the \include\ directory, search for "sort by", then

else if ($orderby = = "Lastpost") {
$ordersql = "ORDER by Arc.lastpost $orderWay";
} This code and

else {
$ordersql = "ORDER by Arc.sortrank $orderWay";
}

Paste the code in the middle of the code that you just copied.

4. Locate the IF (Ereg (' Hot|click|lastpost ', $orderby)) to modify the IF (Ereg (' Hot|click|lastpost|weight ', $orderby)) and save the file.

This time the list page can be sorted using {dede:list pagesize= ' 5 ' orderby= ' weight '}.

second, DEDE 5.7 first page "Arclist" added by weight sort

1. Locate the arclist.lib.php file in the following directory \include\taglib in the Dream system and open

Found at approximately 74, 75 rows:

Arclist If weight sort is required, default is "N" and set to "Y" if sorting is required
$isweight = $ctag->getatt (' isweight ');

Change this line to:

$weight = $ctag->getatt (' weight ');

Found in about 327 rows

How documents are sorted
$ordersql = ";
if ($orderby = = ' Hot ' | | $orderby = = ' click ') $ordersql = "ORDER by Arc.click $orderWay";
else if ($orderby = = ' Sortrank ' | | $orderby = = ' pubdate ') $ordersql = "ORDER by Arc.sortrank $orderWay";
else if ($orderby = = ' id ') $ordersql = "ORDER by arc.id $orderWay";
else if ($orderby = = ' near ') $ordersql = "ORDER by ABS (Arc.id-". $arcid. ")";
else if ($orderby = = ' Lastpost ') $ordersql = "ORDER by Arc.lastpost $orderWay";
else if ($orderby = = ' scores ') $ordersql = "ORDER by Arc.scores $orderWay";
else if ($orderby = = ' Rand ') $ordersql = "ORDER by rand ()";
else $ordersql = "ORDER by Arc.sortrank $orderWay";

Modified to:

How documents are sorted
$ordersql = ";
if ($orderby = = ' Hot ' | | $orderby = = ' click ') $ordersql = "ORDER by Arc.click $orderWay";
else if ($orderby = = ' Sortrank ' | | $orderby = = ' pubdate ') $ordersql = "ORDER by Arc.sortrank $orderWay";
else if ($orderby = = ' id ') $ordersql = "ORDER by arc.id $orderWay";
else if ($orderby = = ' near ') $ordersql = "ORDER by ABS (Arc.id-". $arcid. ")";
else if ($orderby = = ' Lastpost ') $ordersql = "ORDER by Arc.lastpost $orderWay";
else if ($orderby = = ' scores ') $ordersql = "ORDER by Arc.scores $orderWay";
else if ($orderby = = ' Rand ') $ordersql = "ORDER by rand ()";
else if ($orderby = = ' weight ') $ordersql = "ORDER by arc.weight ASC";//If no specific setting is sorted by weight first
else $ordersql = "ORDER by Arc.sortrank $orderWay";

OK now save this document and we can use orderby= ' weight ' in the home page to sort it out.

DEDECMS5.7 Home and column page call articles by weight sort

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.