作者:my76572 | 来源:互联网 | 2013-08-14 15:07
header("Content-type: text/html; charset=utf-8");
import("home.Model.ArticleModel");//跨项目调用 home 项目下的 博客模型 ArticleModel
$articleModel=new ArticleModel();//实例化自定义模型
$root_sort=$articleModel->sort_list('0');//大导航列表
$this->root=$root_sort;
$sortID=$_GET['sortID'];
$sortInfo=$articleModel->get_sort_info($sortID);//当前类别信息
if(isset($sortID)&&$sortID!='0'){
$lm_t=explode(",",$sortInfo['sortPath']);
$count_t=count($lm_t);
if($count_t==3){//当前是一级栏目,要获取本类下的 二级栏目
$son_sort=$articleModel->sort_list($sortID);
$this->son_sort=$son_sort;
}
if($count_t==4){//当前是二级栏目,要获取本类下的三级栏目 (也要获取二级栏目同级目录下的 二级列表)
$parentID=$sortInfo['parentID'];
$son_sort=$articleModel->sort_list($parentID);
$this->son_sort=$son_sort;
$son_son_sort=$articleModel->sort_list($sortID);
$this->son_son_sort=$son_son_sort;
}
if($count_t==5){//当前是三级栏目,不用获取本类下栏目 (要获取三级栏目同级目录下的 三级列表 及 父栏目的同级列表)
$parentID=$sortInfo['parentID'];
$parentInfo=$articleModel->get_sort_info($parentID);//父类别信息
$parent_parent_ID=$parentInfo['parentID'];//父级别的 parentID
$son_sort=$articleModel->sort_list($parent_parent_ID);
$this->son_sort=$son_sort;
$son_son_sort=$articleModel->sort_list($parentID);
$this->son_son_sort=$son_son_sort;
}
}
//分页代码------Start------------------------------------------------------------
$page_one_size=20;
$lists_count=$articleModel->get_article_list_count($sortID);//列表总条数
$page_count=ceil($lists_count/$page_one_size);//总分页数
$this_page_num=$_GET['page'];//页码
if($this_page_num==0||$this_page_num<1||$this_page_num==""){$this_page_num=1;}
$start_id=($this_page_num-1)*$page_one_size;
$lists=$articleModel->get_article_list($sortID,$Condition,"$start_id,$page_one_size");//获取列表内容
// print_r($lists);exit;
$start_page=$this_page_num-5;//页码开始
if($start_page>$page_count-10){$start_page=$page_count-10;}
if($start_page<1){$start_page=1;}
$end_page=$start_page+10;//页码结束
if($end_page>$page_count){$end_page=$page_count;}
$left_page=$this_page_num-1;//上一页
if($left_page<1){$left_page=1;}
$right_page=$this_page_num+1;//下一页
if($right_page>$page_count){$right_page=$page_count;}
$page_str.="
";
$this->page_str=$page_str;
//分页代码------End----------------------------------------------------------------------
//$article_list=$articleModel->get_article_list($sortID,'');
$article_list=$lists;
$this->articles = $article_list;
$this->page_str=$page_str;
$this->display();