Tag Dede: arclist sorting is specified by orderby, as follows:
{Dede: arclist orderby = 'sort field '}
{/Dede: arclist}
Orderby = 'sortrank' Document Sorting Method
§ Orderby = 'hot 'or orderby = 'click' indicates the number of clicks
§ Orderby = 'sortrank' or orderby = 'pubdate' are arranged by publishing time
§ Orderby = 'near'
§ Orderby = 'lastpost' based on the last comment time
§ Orderby = 'scores' sort by score
§ Orderby = 'id' sort by Article ID
§ Orderby = 'rand' randomly obtain the list of documents with specified conditions
The value assigned to orderby can only be the values listed above, that is, the Dede: arclist tag can only be sorted by the fields listed above.
So how can we sort by custom fields? Assume that I have added the orderid field to the dede_archives table,
I want to sort by this field. You cannot directly write: {Dede: arclist orderby = 'orderid. So how should we modify it?
I. database operations:
Modify the structure of the dede_archives table using the MySQL management tool or other tools and add an orderid Field
2. Modify background files
1. Open Dede/article_add.php // modify the code file.
Modify line 187-191 to the following code:
$ Query = "insert into '#@__ archives' (ID, typeid, typeid2, sortrank, flag, ismake, channel, arcrank, click, money, title, category title,
Color, writer, source, litpic, pubdate, senddate, mid, notpost, description, keywords, filename, dutyadmin, orderid)
Values ('$ arcid',' $ typeid', '$ typeid2',' $ sortrank ',' $ flag ',' $ ismake ',' $ channelid ', '$ arcrank', '$ click',' $ money ',
'$ Title',' $ category title', '$ color',' $ writer', '$ source',' $ litpic ',' $ pubdate ',' $ senddate ',
'$ Adminid',' $ notpost', '$ description',' $ keyword', '$ filename', '$ adminid', '$ orderid ');";
2. Open Dede/article_edit.php // modify the code file.
Add a comma after dutyadmin = '$ adminid' in row 191,
Enter the line feed and add the following code: orderid = '$ orderid'
3. Open Dede/templets/article_add.htm // modify the template file.
Find row 134, press enter to add a line, and add the following code:
<Table width = "800" border = "0" cellspacing = "0" cellpadding = "0">
<Tr>
<TD width = "90" style = "color: # f00"> & nbsp; Sorting weight: </TD>
<TD colspan = "3"> <input type = 'text' name = 'orderid' value = '0' style = 'width: 100px; '/> (enter a number,) </TD>
</Tr>
</Table>
4. Open Dede/templets/article_edit.html // modify the template file.
To line 2, press enter to add a line and add the following code:
<Table width = "800" border = "0" cellspacing = "0" cellpadding = "0">
<Tr>
<TD width = "90" style = "color: # f00"> & nbsp; Sorting weight: </TD>
<TD colspan = "3"> <input type = 'text' name = 'orderid' value = '<? PHP echo $ arcrow ["orderid"]?> 'Style = 'width: 100px; '/> (enter a number. The larger the value, the higher the value.) </TD>
<TD> </TD>
</Tr>
</Table>
PS: Steps 3rd and 4 are not suitable for beginners of the HTML language. If you are a veteran, you can decide to add a location on your own.
3. Foreground file operations:
1. Open include/arc. listview. Class. php // modify the code file.
To line 2, press enter to add a line and add the following code:
Else if ($ orderby = "orderid "){
$ Ordersql = "order by arc. orderid $ orderway"; // The orderid is the self-added field in the dede_archives table.
}
2. Open include/taglib/arclist. Lib. php // modify the code file.
To line 2, press enter to add a line and add the following code:
Else if ($ orderby = 'orderid') $ ordersql = "order by arc. orderid $ orderway, arc. Id $ orderway ";
In this way, you can implement the operation of custom fields, the UTF-8 version can be similar to the modification.
Iv. html template calls are as follows:
{Dede: arclist typeid = '2' ROW = '11' titlelen = '42' orderby = 'orderid' orderway = 'desc '}
.................
{/Dede: arclist}