[Bug]点击导航话题默认显示未分类话题

点击导航话题默认显示未分类话题,理解应该默认显示所有话题。

请先 登录 后评论

最佳答案 2017-08-24 00:11

这个问题我以前就发现了,不过如果你懂一点PHP和laravel框架的话,可以自己修改控制器

我贴一下我修改的控制器IndexController.php 修改第157行,仅供参考

public function topic( $categorySlug='all')
{

$currentCategoryId = 0;
if( $categorySlug != 'all' ){
$category = Category::where("slug","=",$categorySlug)->first();
if(!$category){
abort(404);
}
$currentCategoryId = $category->id;
}

$categories = load_categories('tags');

if ($currentCategoryId > 0 ){
$topics = Tag::where("category_id","=",$currentCategoryId)->orderBy('followers','DESC')->paginate(20);
}
else{
$topics = Tag::where("category_id",">=",0)->orderBy('followers','DESC')->paginate(20);
}

return view('theme::home.topic')->with(compact('category','topics','categories','currentCategoryId','categorySlug'));
}

PS:我只是为了测试一下空格回复是否产生BUG,提交成功,结果还真成功了,又无法删除,为了证明我不是捣乱的人,就重新编辑认真的回复了一下


请先 登录 后评论

其它 0 个回答

  • 1 关注
  • 0 收藏,3830 浏览
  • Bruce 提出于 2017-08-23 00:17

相似问题