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} |
Method:
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} |