Enable the list tag of dedecms to support multi-field sorting

Source: Internet
Author: User

The orderby attribute of the woven dream list tag can only be sorted by one Field. If you want to sort Multiple Fields, I have modified PHP in the background to support multi-field sorting. The modification is as follows:

 

Find the Arc. listview. Class. php file in the main directory include folder, and find

 

// If you do not use the default sortrank or ID sorting, use the Combined Query (when the data volume is large, it is very slow)
If (preg_match ('/hot | click | lastpost | title/', $ orderby ))
{
$ Query = "select arc. *, TP. typedir, TP. typename, TP. isdefault, TP. defaultname,
TP. namerule, TP. namerule2, TP. ispart, TP. moresite, TP. siteurl, TP. sitepath
$ Addfield
From '#@__ archives' arc
Left join '# @__ arctype 'tp on Arc. typeid = TP. ID
$ Addjoin
Where {$ this-> addsql} $ ordersql limit $ limitstart, $ row ";
}
// In normal cases, first identify the ID from the arctiny table and then query by ID (FAST)
Else
{
$ T1 = exectime ();
$ IDs = array ();
$ Query = "select ID from '#@__ arctiny' arc where {$ this-> addsql} $ ordersql limit $ limitstart, $ row ";
$ This-> dsql-> setquery ($ query );
$ This-> dsql-> execute ();
While ($ arr = $ this-> dsql-> getarray ())
{
$ IDs [] = $ arr ['id'];
}
$ Idstr = join (',', $ IDs );
If ($ idstr = '')
{
Return '';
}
Else
{
$ Query = "select arc. *, TP. typedir, TP. typename, TP. corank, TP. isdefault, TP. defaultname,
TP. namerule, TP. namerule2, TP. ispart, TP. moresite, TP. siteurl, TP. sitepath
$ Addfield
From '##__ archives 'arc left join' ##__ arctype 'tp on Arc. typeid = TP. ID
$ Addjoin
Where arc. ID in ($ idstr) $ ordersql ";
}
$ T2 = exectime ();
// Echo $ t2-$ T1;

}

Replace

If ($ orderby = "default ")
{
$ T1 = exectime ();
$ IDs = array ();
$ Query = "select ID from '#@__ arctiny' arc where {$ this-> addsql} $ ordersql limit $ limitstart, $ row ";
$ This-> dsql-> setquery ($ query );
$ This-> dsql-> execute ();
While ($ arr = $ this-> dsql-> getarray ())
{
$ IDs [] = $ arr ['id'];
}
$ Idstr = join (',', $ IDs );
If ($ idstr = '')
{
Return '';
}
Else
{
$ Query = "select arc. *, TP. typedir, TP. typename, TP. corank, TP. isdefault, TP. defaultname,
TP. namerule, TP. namerule2, TP. ispart, TP. moresite, TP. siteurl, TP. sitepath
$ Addfield
From '##__ archives 'arc left join' ##__ arctype 'tp on Arc. typeid = TP. ID
$ Addjoin
Where arc. ID in ($ idstr) $ ordersql ";
}
$ T2 = exectime ();
// Echo $ t2-$ T1;

}
Else
{
$ Query = "select arc. *, TP. typedir, TP. typename, TP. isdefault, TP. defaultname,
TP. namerule, TP. namerule2, TP. ispart, TP. moresite, TP. siteurl, TP. sitepath
$ Addfield
From '#@__ archives' arc
Left join '# @__ arctype 'tp on Arc. typeid = TP. ID
$ Addjoin
Where {$ this-> addsql} $ ordersql limit $ limitstart, $ row ";
}

Find

Else {
$ Ordersql = "order by arc. sortrank $ orderway ";
}

Replace

Else if ($ orderby = "default "){
$ Ordersql = "order by arc. sortrank $ orderway ";
}
Else {
$ Ordersql = "order by". $ orderby. ", arc. sortrank $ orderway ";
}

Now you can apply Multi-field sorting in the template,

The template application is as follows:

{Dede: List pagesize = '17' orderby = 'arc. Title DESC, arc. id '}

 

Related Article

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.