Ejemplo n.º 1
0
 /**
  * 文章新闻
  *
  */
 function index()
 {
     $model = D('Article');
     switch (true) {
         case isset($_REQUEST['id']):
             //单独文章
             $list = $model->find(intval($_REQUEST['id']));
             //副标题
             if (empty($list['title2'])) {
                 $list['title2'] = $list['title'];
             }
             if (!$list) {
                 parent::_empty();
                 return;
             }
             if ($next = $model->where('pid=' . $list['pid'] . ' and id>' . $list['id'])->getField('id')) {
                 $this->next = U('Article/' . $next);
             }
             if ($prev = $model->where('pid=' . $list['pid'] . ' and id<' . $list['id'])->getField('id')) {
                 $this->prev = U('Article/' . $prev);
             }
             if ($list['pid']) {
                 $this->nav = get_cate_nav($list['pid']);
             }
             $this->pagetitle = $list['title'];
             $this->pagekeywords = $list['keywords'];
             $this->pagedesc = $list['description'];
             $this->assign($list);
             $this->display('Article');
             break;
         case isset($_REQUEST['pid']):
             //文章列表
             $map['pid'] = intval($_REQUEST['pid']);
             $model->_list($this->view, $map, 'id', false);
             $model = D('Article_cate');
             //seo
             $cate = $model->where(array('id' => intval($_REQUEST['pid'])))->find();
             //副标题
             if (empty($cate['name2'])) {
                 $cate['name2'] = $cate['name'];
             }
             $this->pagetitle = $cate['name'];
             $this->pagekeywords = $cate['keywords'];
             $this->pagedesc = $cate['description'];
             $this->disp_text = $cate['name'];
             $this->display('Article_list');
             break;
         default:
             parent::_empty();
             return;
             /*default:
             		$this->disp_text="Article list";//所有列表
             		$map['title']=array('neq','底部版权');
             		$model->_list($this->view,$map,'id',false);
             		$this->display ('Home:Article_list');*/
     }
 }
Ejemplo n.º 2
0
 function article($aid)
 {
     parent::$Model = D('Article');
     if (is_numeric($aid)) {
         $list = parent::$Model->where($map)->find($aid);
     } else {
         $title = auto_charset($aid, 'utf-8', 'gbk');
         if (strcasecmp($title, 'sitemap') == 0) {
             $this->sitemap();
             return;
         }
         if (strcasecmp($title, 'contact-us') == 0) {
             $this->contact_us();
             return;
         }
         if (strcasecmp($title, 'FAQs') == 0) {
             $this->FAQs();
             return;
         }
         if (strcasecmp($title, 'News') == 0) {
             $this->News();
             return;
         }
         $article_cache = md5('article_' . $title);
         if (S($article_cache) == '') {
             $map['title'] = $title;
             $map['title2'] = $title;
             //自定义文章URL用
             $map['_logic'] = 'or';
             $list = parent::$Model->where($map)->find();
             //副标题
             if (empty($list['title2'])) {
                 $list['title2'] = $list['title'];
             }
             $list ? $list['title'] = str_replace("-", " ", $list['title']) : '';
             S($article_cache, $list);
         }
         if (!empty($list['href'])) {
             redirect($list['href']);
             die;
         }
         $list = S($article_cache);
     }
     if ($list) {
         $this->assign($list);
         $this->pagetitle = $list['title'];
         $this->pagekeywords = $list['keywords'];
         $this->pagedesc = $list['description'];
         $this->display("Empty:Article");
     } else {
         parent::_empty();
         return;
     }
 }