public function index(){
C('TOKEN_ON',false);//关闭表单令牌 读取配置
//查询指定id的栏目信息
$id=I('get.id');//类别ID
$topcate=M('Column')->where("id=$id")->order('column_sort')->select(); //查询文章
// dump($topcate);
// exit;
//查询所有栏目的信息
$m=M('Column')->order('column_sort')->select();
// dump($m);
// exit;
//查询指定id的栏目下的所有文章 无限分类
foreach ($topcate as $k => $v){ //$k是索引 $v是值
$cids=Category::getChildsId($m, $v['id']);//传递一个父级分类ID返回所有子分类ID
$cids[]=$v['id'];//将父级id也压进来赋值给$cids
// dump($cids);
// exit;
//查询数据,没有分页
$where=array('nv_id'=>array('IN', $cids));//查询新闻表nv_id字段和$cids相等时的数据
//$News=('News');
$topcate[$k]['news']=D('News')->where($where)->where("news_dell=0")->relation(true)->select();
$result=$topcate[$k]['news']; //二维数组
//以此将循环出来的值赋给$topcate二维数组 当$k=0时候是一个值 当$l=1是 一个值
// dump($result);
// exit;
//**分页实现代码
$count = count($result);// 查询满足要求的总记录数
$Page = new \Think\Page($count,15);// 实例化分页类 传入总记录数和每页显示的记录数(25)
$show = $Page->show();// 分页显示输出
//**分页实现代码
//查询数据,没有分页
$where=array('nv_id'=>array('IN', $cids));//查询新闻表nv_id字段和$cids相等时的数据
//$News=('News');
$topcate[$k]['news']=D('News')->where($where)->where("news_dell=0")->relation(true)->limit($Page->firstRow.','.$Page->listRows)->order('news_sort,id desc')->select();
$result=$topcate[$k]['news'];
}
//循环截取字符 substr_ext函数写在commonaction.class.php中
foreach($result as $k2 => $v2){
$result[$k2]['news_title'] = Common::substr_ext($v2['news_title'], 0, 16, 'utf-8',"");
}
// dump($result);
// exit;
//**分页实现代码
$this->assign('page',$show);// 赋值分页输出
$this->assign('count',$count);// 查询总共多少条记录数
$this->assign('module',MODULE_NAME);// 赋值分页输出
//**分页实现代码
$this->assign('vcolumn',$topcate);
$this->assign('vlist',$result);
$this->assign('nav',$id); //查询制定栏目id的显示
$this->display();
}