public function index($catsid = 0)
 {
     //列表过滤器,生成查询Map对象
     $map = $this->_search('Article');
     if (method_exists($this, '_filter')) {
         $this->_filter($map);
     }
     $model = D('Article');
     $map['islock'] = 0;
     //增加搜索条件,列出各自分类下文章
     $map['tid'] = array('in', getChildrenId($catsid));
     // $map['tid'] = $catsid;
     if (!empty($model)) {
         $this->_list($model, $map);
     }
     //栏目id
     $this->assign('catsid', $catsid);
     $navTabUrl = "index/catsid/" . $catsid;
     $this->assign('navTabUrl', $navTabUrl);
     if ($catsid == 72 || $catsid == 73) {
         $this->display("listCard");
     } else {
         $this->display("listNormal");
     }
     return;
 }
 public function index()
 {
     $category_id = $this->_get('category_id');
     $category = M('category')->select();
     $children_id = getChildrenId($category, $category_id);
     $children_id[] = $category_id;
     //p($children_id);die;
     import('ORG.Util.Page');
     $where = array('post.category_id' => array('IN', $children_id), 'post.parent_id' => 0);
     if (!isset($_GET['category_id'])) {
         $where = array('post.parent_id' => 0);
     }
     //精品帖
     $tag_id = isset($_GET['tag_id']) ? $_GET['tag_id'] : 0;
     if ($tag_id) {
         $post_id_list = array();
         $result = M('post_tag')->where(array('tag_id' => $tag_id))->select();
         if ($result) {
             foreach ($result as $key => $value) {
                 $post_id_list[] = $value['post_id'];
             }
         }
         $where = array('post.parent_id' => 0, 'post.post_id' => array('in', $post_id_list), 'post.is_recycle' => 0);
     }
     $db = D('Post');
     //分页
     $count = $db->where($where)->count();
     $page = new Page($count, 20);
     $limit = $page->firstRow . ',' . $page->listRows;
     //echo $id;
     $post = $db->relation(true)->where($where)->order('update_time DESC')->limit($limit)->select();
     //$post=D('PostUserView')->select();
     //p($post);
     $location = array_reverse(get_all_parent($category, $_GET['category_id']));
     if (!isset($_GET['category_id'])) {
         $where = array('parent_id' => 0);
         $children_category = M('category')->where($where)->select();
     } else {
         $children_category = M('category')->where(array('parent_id' => $category_id))->select();
         if (!$children_category) {
             $parent_category = M('category')->where(array('category_id' => $category_id))->getField('parent_id');
             $where = array('parent_id' => $parent_category);
             $children_category = M('category')->where($where)->select();
         }
     }
     $this->post = $post;
     $this->page = $page->show();
     $this->category_id = $category_id;
     $this->location = $location;
     $this->children_category = $children_category;
     $this->display();
 }
Example #3
0
function getChildrenId($array, $parent_id)
{
    static $children_id = array();
    if (is_array($array) && $array) {
        foreach ($array as $k => $v) {
            if ($v['parent_id'] == $parent_id) {
                $children_id[] = $v['category_id'];
                getChildrenId($array, $v['category_id']);
            }
        }
    }
    return $children_id;
}
 public function rec_project()
 {
     //列表过滤器,生成查询Map对象
     $map = $this->_search('Article');
     $arr = array_merge(getChildrenId('71'));
     $map['tid'] = array('in', $arr);
     $map['ispush'] = 1;
     $map['islock'] = 0;
     $model = D('Article');
     if (!empty($model)) {
         $this->_list($model, $map, 'sort', 'asc');
     }
     $this->assign('navTabUrl', 'rec_project');
     $this->display('index');
     return;
 }
Example #5
0
 public function index()
 {
     $cats = D('Category');
     $link = M('link');
     $portrait = M('Member_user');
     $article = M('article');
     //首页banner图展示
     $banner = M('banner')->where('isshow = 1')->order('sort asc')->select();
     $this->assign('banner', $banner);
     $this->assign('ulWidth', count($banner) * 20);
     //首页7篇文章推荐展示
     $arr = array_merge(getChildrenId('71'), getChildrenId('74'), getChildrenId('75'));
     $map['tid'] = array('in', $arr);
     $map['ispush'] = 1;
     $map['islock'] = 0;
     $recArticle = $article->where($map)->order('sort asc')->limit(7)->select();
     $this->assign('recArticle', $recArticle);
     //首页3个项目推荐
     $arr = array_merge(getChildrenId('71'));
     $map['tid'] = array('in', $arr);
     $map['ispush'] = 1;
     $map['islock'] = 0;
     $recProject = $article->where($map)->order('sort asc')->limit(3)->select();
     $this->assign('recProject', $recProject);
     //首页人物或者机构推荐
     $map['tid'] = 87;
     $map['ispush'] = 1;
     $map['islock'] = 0;
     $recOrg = $article->where($map)->order('sort asc')->limit(3)->select();
     $this->assign('recOrg', $recOrg);
     //首页媒体推荐
     $map['tid'] = 85;
     $map['ispush'] = 1;
     $map['islock'] = 0;
     $recMedia = $article->where($map)->order('sort asc')->limit(3)->select();
     $this->assign('recMedia', $recMedia);
     //显示模板
     $this->display('index');
 }