/** * [artice 文章内容] * @return [type] [description] */ public function artice($slug) { $webSite = Website::find(1)->toArray(); $arcData = Article::with('belongsToCategory')->find($slug)->toArray(); //print_r($arcData); $hotArcData = Article::with('belongsToCategory')->where(['is_del' => 0])->get()->toArray(); $linkData = Link::where(['is_look' => 1])->get()->toArray(); //print_r($linkData); $cateData = Category::where(['is_del' => 0])->get()->toArray(); //print_r($cateData); $item = []; foreach ($cateData as $k => $v) { if (!isset($item[$v['id']])) { $item[$v['id']] = $v; } else { $item[$v['id']] = $v; } } //上一篇 $pre = Article::get_pre($slug); //print_r($pre); //下一篇 $next = Article::get_next($slug); //print_r($next); //相关文章 $this->smarty->assign('pre', $pre); $this->smarty->assign('next', $next); $this->smarty->assign('webSite', $webSite); $this->smarty->assign('hotArcData', $hotArcData); $this->smarty->assign('cateData', $item); $this->smarty->assign('slug', $slug); $this->smarty->assign('linkData', $linkData); $this->smarty->assign('article', $arcData); $this->smarty->display('Index/article.html'); }