Просмотр исходного кода

资讯详情下的相关信息

binbinyouli 5 лет назад
Родитель
Сommit
80ac37cee4
1 измененных файлов с 9 добавлено и 4 удалено
  1. 9 4
      app/index/controller/NewsController.php

+ 9 - 4
app/index/controller/NewsController.php

@@ -52,7 +52,7 @@ class NewsController extends HomeBaseController
      * @throws \think\db\exception\ModelNotFoundException
      * @throws \think\exception\DbException
      */
-    public function show(){
+    public function show(){    
         $param = $this->request->param();
         isset($param['id']) or $this->error('非法访问');
         $cacheKey = 'cache:news_pages:show_' . $param['id'].'_'.intval(cmf_is_mobile());
@@ -61,7 +61,7 @@ class NewsController extends HomeBaseController
         Db::name('jiameng')->where('id', $param['id'])->setInc('hits', 1);
 
         if ($pageHtml) {
-            return $pageHtml;
+          //  return $pageHtml;
         }
 
         $info = Db::name('news')->where('id',$param['id'])->where('status',1)->find();
@@ -108,9 +108,14 @@ class NewsController extends HomeBaseController
 
         // 相关资讯
         $other_news = NewsService::getListByCate($info['ncatid'], 10);
-
+        $id=$param['id'];
         //相关动态和品牌动态   2020-08-24
-        $about_news = Db::name('news')->field('id,title,thumb,create_time')->where(['ncatid'=>1,'status'=> 1])->order('id desc')->limit(6)->select();  
+        $about_news = Db::name('news')->field('id,title,thumb,create_time')->where(['status'=> 1])
+        ->where(function($query) use ($id){
+            $query->where('id','gt',$id);
+        })
+        ->order('list_order')->limit(6)->select();  
+
         $brand_news = Db::name('news')->field('id,title,thumb,create_time')->where(['catid'=>$info['catid'],'status'=> 1])->order('id desc')->limit(6)->select();
 
         $keywords = [];