/** * 兼容旧式CMS深目录结构的二级cat结构 * @param $info */ public function channel($info) { //TODO 兼容旧式CMS深目录结构的二级cat结构 $Cat = new CatsLogic(); $cat = $Cat->detail($info); $children = $Cat->getChildren($cat['cat_id']); $Cat = new CatsLogic(); $Posts = new PostsLogic(); $cat = $Cat->detail($info); $this->if404($cat, "非常抱歉,没有这个分类,可能它已经躲起来了"); //优雅的404 $posts_id = $Cat->getPostsId($cat['cat_id']); $count = sizeof($posts_id); $count == 0 ? $res404 = 0 : ($res404 = 1); if (!empty($posts_id)) { $Page = new GreenPage($count, get_opinion('PAGER')); $pager_bar = $Page->show(); $limit = $Page->firstRow . ',' . $Page->listRows; $posts_list = $Posts->getList($limit, 'single', 'post_id desc', true, array(), $posts_id); } $this->assign('children', $children); $this->assign('title', $cat['cat_name']); // 赋值数据集 $this->assign('res404', $res404); $this->assign('postslist', $posts_list); // 赋值数据集 $this->assign('pager', $pager_bar); // 赋值分页输出 $this->assign('breadcrumbs', get_breadcrumbs('cats', $cat['cat_id'])); $this->display('Archive/channel-list'); }
/** * 兼容旧式CMS深目录结构的二级cat结构 * @param $info */ public function channel($info) { //TODO 兼容旧式CMS深目录结构的二级cat结构 $CatsLogic = new CatsLogic(); $cat = $CatsLogic->detail($info); $children = $CatsLogic->getChildren($cat['cat_id']); if (empty($children['cat_children'])) { $children = $CatsLogic->getChildren($children['cat_father']); } $CatsLogic = new CatsLogic(); $Posts = new PostsLogic(); $cat = $CatsLogic->detail($info); $this->if404($cat, "非常抱歉,没有这个分类,可能它已经躲起来了"); //优雅的404 $posts_id = $CatsLogic->getPostsIdWithChildren($cat['cat_id']); $count = sizeof($posts_id); $count == 0 ? $res404 = 0 : ($res404 = 1); if (!empty($posts_id)) { $Page = new GreenPage($count, get_opinion('PAGER')); $pager_bar = $Page->show(); $limit = $Page->firstRow . ',' . $Page->listRows; $posts_list = $Posts->getList($limit, 'single', 'post_date desc', true, array(), $posts_id); } $this->assign('children', $children); $this->assign('title', $cat['cat_name']); // 赋值数据集 $this->assign('res404', $res404); $this->assign('postslist', $posts_list); // 赋值数据集 $this->assign('pager', $pager_bar); // 赋值分页输出 $this->assign('breadcrumbs', get_breadcrumbs('cats', $cat['cat_id'])); if (File::file_exists(T('Home@Archive/channel-list'))) { $this->display('Archive/channel-list'); } else { //TODO 这里怎么处理却决于你自己了。 // $this->error404('缺少对应的模版而不能显示'); $this->display('Archive/single-list'); } }
/** * 父类与子类分类列表 * @usage {:W('Widget/catSidebar',array("cat_id"=>$cat_id))} */ public function catSidebar($cat_id = 0, $default_title) { if ($cat_id == null) { $this->assign('cat_sidebar_title', $default_title); // 赋值数据集 $CatList = new CatsLogic(); $Cat = new \Common\Util\Category('Cats', array('cat_id', 'cat_father', 'cat_name', 'cat_name')); $children['cat_children'] = $Cat->getList(); foreach ($children['cat_children'] as $key => $value) { $children['cat_children'][$key]['cat_children'] = $children['cat_children'][$key]; } $this->assign('children2', $children); } else { $Cat = new CatsLogic(); $children = $Cat->getChildren($cat_id); if (empty($children['cat_children'])) { //无子类处理 if ($children['cat_father'] == 0) { //无父类 $this->assign('cat_sidebar_title', $children["cat_name"]); // 赋值数据集 } else { //有父类 $children2 = $Cat->getChildren($children['cat_father']); $this->assign('cat_sidebar_title', $children2["cat_name"]); // 赋值数据集 $this->assign('children2', $children2); } } else { //有子类处理 $this->assign('cat_sidebar_title', $children["cat_name"]); // 赋值数据集 $this->assign('children2', $children); } } $this->assign('cat_id', $cat_id); // 赋值数据集 $this->display('Widget:cat_sidebar'); }