diff --git a/app/index/controller/Index.php b/app/index/controller/Index.php index ac863ee..dfd7650 100644 --- a/app/index/controller/Index.php +++ b/app/index/controller/Index.php @@ -100,30 +100,30 @@ class Index extends BaseController $map[] = ['status','=',1]; //这里等号不能省略 //实现搜索功能 - $keywords = input('keywords'); - if(!empty($keywords)){ + $keywords = Request::only(['keywords']); + //var_dump($keywords['keywords']); + if(!empty($keywords['keywords'])){ //条件2 - $map[] = ['title','like','%'.$keywords.'%']; + $map[] = ['title','like','%'.$keywords['keywords'].'%']; $artList = Article::where($map)->withCount('comments')->order('create_time','desc')->paginate(10); $counts = $artList->count(); $searchs = [ 'artList' => $artList, - 'keywords' => $keywords, + 'keywords' => $keywords['keywords'], 'counts' => $counts - ]; - + ]; + + } else { + return response('输入非法'); + } View::assign($searchs); - //友情链接 - $friend_links = Db::name('friend_link')->field('linkname,linksrc')->select(); - View::assign('flinks',$friend_links); + //友情链接 + $friend_links = Db::name('slider')->where(['slid_status'=>1,'delete_time'=>0,'slid_type'=>6])->whereTime('slid_over','>=',time())->field('slid_name,slid_href')->select(); // 查询热议 $artHot = Article::withCount('comments')->field('title,comments_count')->where('status',1)->whereTime('create_time', 'year')->order('comments_count','desc')->limit(10)->select(); - View::assign('artHot',$artHot); - - } else{ - return '请输入关键词'; - } + + View::assign(['flinks'=>$friend_links,'artHot'=>$artHot]); return View::fetch('search'); } diff --git a/view/index/article/cate.html b/view/index/article/cate.html index 86c2268..6e21fa1 100644 --- a/view/index/article/cate.html +++ b/view/index/article/cate.html @@ -92,7 +92,6 @@ - {/block} {block name="script"} + {/block} \ No newline at end of file diff --git a/view/index/article/detail.html b/view/index/article/detail.html index fafecaf..47174a7 100644 --- a/view/index/article/detail.html +++ b/view/index/article/detail.html @@ -264,7 +264,6 @@ $(function() { }); }); - + {/block} \ No newline at end of file diff --git a/view/index/index/index.html b/view/index/index/index.html index fa88974..3cdffa4 100644 --- a/view/index/index/index.html +++ b/view/index/index/index.html @@ -211,7 +211,6 @@ {/block} {block name="script"} - - + {/block} \ No newline at end of file diff --git a/view/index/index/search.html b/view/index/index/search.html index 9c377f1..d54be81 100644 --- a/view/index/index/search.html +++ b/view/index/index/search.html @@ -67,19 +67,19 @@ TP5学习制作:Tao.2019