广告

您的位置 首页 新闻中心 Webmeng升级【最新发布在前面】Webmeng文章分类排序问题

【最新发布在前面】Webmeng文章分类排序问题

Webmeng文章分类排序问题(最新发布在前面)

 public function _category($catid)
{

$catid = str_replace("category_","",$catid);
$catid=(int) $catid;

$search='';
if(!empty($catid)){
$sortpath=$this->db->fetch_one("select sort_path from ".WEBMENG_CONMENG."category_record where cat_id='".$catid."'  ");
$search.=" and catid in(select cat_id from ".WEBMENG_CONMENG."category_record where sort_path like '".$sortpath."%') ";
}

$sql = "select *,thumb as img,inputtime as addtime from ".WEBMENG_CONMENG."record where catid='".$catid."' order by inputtime desc ";


$all_record = page_for_db_extend($sql);  //查询带分页的
$data = array(
'info_reslut' => $all_record['data'],
'showpage'    => $all_record['page'],
'category'   => $this->_category_record()
);

$settings = array();
$sets = $this->db->fetch("select * from ".WEBMENG_CONMENG."settings  ");
if(!empty($sets)){
foreach ($sets as $v) {
$webmeng[$v['variable']] = $v;
}
}
$data['webmeng'] = $webmeng;    /*获取内页调用系统信息如LOGO 网站名称*/




$this->display('record/category.html',$data);
}



public function _category_record()
{




$record_list  = $this->db->fetch("select cat_name as sortname,cat_id as id,parent_id from ".WEBMENG_CONMENG."category_record  ");
$category = array();
$parent = array();
if(!empty($record_list)){
foreach ($record_list as  $v) {
if($v['parent_id']==0){
$category[] = $v;
}
$parent[$v['parent_id']][]=$v;
}
foreach ($category as $k => $v) {
$category[$k]['child'] = isset($parent[$v['id']])?$parent[$v['id']]:array();
if(!empty($category[$k]['child'])){
foreach ($category[$k]['child'] as $key => $value) {
$category[$k]['child'][$key]['child'] = isset($parent[$value['id']])?$parent[$value['id']]:array();
}
}
}
}
return $category;
}

免责声明:
本站部份内容系网友自发上传与转载,不代表本网赞同其观点;
如涉及内容、版权等问题,请在30日内联系,我们将在第一时间删除内容!

作者: admin

为您推荐

发表评论

admin
联系我们

联系我们

13585720501

在线咨询: QQ交谈

邮箱: ser@webmeng.net

关注微信
微信扫一扫关注我们

微信扫一扫关注我们