/** * 查询指定标签的详细信息 * @param $info detail 查询的 id 或者slug */ public function detail($info) { $TagsLogic = new TagsLogic(); $PostsLogic = new PostsLogic(); $tag = $TagsLogic->detail($info); $this->if404($tag, "非常抱歉,没有这个标签,可能它已经躲起来了"); $posts_id = $TagsLogic->getPostsId($tag['tag_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 = $PostsLogic->getList($limit, 'single', 'post_id desc', true, array(), $posts_id); } $this->assign('title', $tag['tag_name']); // 赋值数据集 $this->assign('res404', $res404); $this->assign('postslist', $posts_list); // 赋值数据集 $this->assign('pager', $pager_bar); // 赋值分页输出 $this->assign('breadcrumbs', get_breadcrumbs('tags', $tag['tag_id'])); $this->display('Archive/single-list'); }
/** * 编辑标签 * @param $id */ public function editTag($id) { $TagsLogic = new TagsLogic(); $action = '编辑'; $this->assign('action', $action); $tag = $TagsLogic->detail($id); $this->assign('tag', $tag); $this->display(); }
/** * 标签文章 * @param int $id 指定标签的文章 */ public function tag($id) { $Tag = new TagsLogic(); $Posts = new PostsLogic(); $tag = $Tag->detail($id); $posts_id = $Tag->getPostsId($tag['cat_id']); $count = sizeof($posts_id); if (!empty($posts_id)) { $Page = new GreenPage($count, get_opinion('PAGER')); $limit = $Page->firstRow . ',' . $Page->listRows; $res = $Posts->getList($limit, 'single', 'post_date desc', true, array(), $posts_id); foreach ($res as $key => $value) { $res[$key]['post_content'] = strip_tags($res[$key]['post_content']); $res[$key]['post_url'] = U('Api/Index/post', array('id' => $res[$key]['post_id']), false, true); $res[$key]["post_img"] = get_post_img($value); } $res_array["posts"] = $res; $this->jsonReturn(1, $res_array); } else { $res_array["detail"] = "没有文章"; $this->jsonReturn(0, $res_array); } }