DEDECMS给list标签加上多字段排序功能,DEDE技术
导读:DEDE技术DEDE技术dedecms的list标签orderby属性只支持按一个字段排序,假如想多个字段排序的话,就需要对PHP举办修改,使其可以支持多字段排序,修改如下:打开incdede模板下载dede网站模板。
dedecms的list标签orderby属性只支持按一个字段排序,假如想多个字段排序的话,就需要对PHP举办修改,使其可以支持多字段排序,修改如下:
打开include/arc.listview.class.php,找到:
//假如不消默认的sortrank或id排序,利用连系查询(数据量大时很是迟钝) 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 `js_archives` arc LEFT JOIN `js_arctype` tp ON arc.typeid=tp.id $addJoin WHERE {$this->addSql} $ordersql LIMIT $limitstart,$row"; } //普通环境先从arctiny表查出ID,然后按ID查询(速度很是快) else { $t1 = ExecTime(); $ids = array(); $query = "SELECT id FROM `js_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.m手机模板dedeoresite,tp.siteurl,tp.sitepath $addField FROM `js_archives` arc LEFT JOIN `js_arctype` tp ON arc.typeid=tp.id $addJoin WHERE arc.id in($idstr) $ordersql "; } $t2 = ExecTime(); //echo $t2-$t1; }替换为:
if($orderby=="default") { $t1 = ExecTime(); $ids = array(); $query = "SELECT id FROM `js_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 `js_archives` arc LEFT JOIN `js_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 `js_archives` arc LEFT JOIN `js_arctype` tp ON arc.typeid=tp.id $addJoin WHERE {$this->addSql} $ordersql LIMIT $limitstadede下瓻模板下载rt,$row"; }声明: 本文由我的SEOUC技术文章主页发布于:2023-07-19 ,文章DEDECMS给list标签加上多字段排序功能,DEDE技术主要讲述标签,字段,CMS网站建设源码以及服务器配置搭建相关技术文章。转载请保留链接: https://www.seouc.com/article/web_30315.html