Solution to invalid weight sorting by zhimeng cms

Source: Internet
Author: User
Tags ereg

Dedecms5.7 has a bug in weight sorting. Next I will show you how to solve weight's invalid solution step by step. For details, refer to the following.

The file involved is the includetaglibarclist. lib. php file:

About 570th rows:

The Code is as follows: Copy code
If ($ isweight = 'y ')

This line of code is useless, $ orderWeight = list_sort_by ($ orderWeight, 'weight', 'asc '); sorts the results.

This is problematic, because the statement for retrieving the document table before getting this $ orderWeight 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

Obviously, when we write tags, we write

The Code is as follows: Copy code

{Dede: arclist orderby = 'weight' typeid = '29' isweight = 'y'

Limit = '4, 1' titlelen = '000000' infolen = '000000 ′}

The intention is to sort the data by weight.

For the database retrieved by sortrank, the specified isweight = 'y' only starts to sort the retrieved dataset according to weight.

Therefore, the solution is very simple: Add a weight-ordered processing statement at the 330 rows of the program file:

The Code is as follows: Copy code

Else if ($ orderby =

'Weight') $ ordersql = "order by arc. weight asc ";

Let's separate a list tag to support weight sorting.

The Code is as follows: Copy code

{Dede: list pagesize = '10' titlelen = '50' orderby = 'weight'} • [field: textlink/] <br/> {/dede: list}


1. Open the arc. listview. class. php file.

2. Find the "else if ($ orderby =" lastpost ") {" Statement, which is about 609 rows. Press enter before this line to insert the following statement:

The Code is as follows: Copy code

Else if ($ orderby = "weight") {$ ordersql = "order by arc. weight $ orderWay ";}

3. Continue to find the "if (ereg ('hot | click | lastpost', $ orderby)" Statement and change it:

The Code is as follows: Copy code

If (ereg ('hot | click | weight | lastpost', $ orderby ))

Save the modification. If weight sorting has been used in the target, generate it and you will see that weight sorting has been installed in the document list.

4. template call

The Code is as follows: Copy code

{Dede: arclist row = '10' titlelen = '50' orderby = 'weight'} • [field: textlink/] <br/> {/dede: arclist}

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: 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.