cate rewrite
This commit is contained in:
parent
2da915d945
commit
95c8d61c0a
@ -6,10 +6,10 @@ use think\facade\View;
|
||||
use think\facade\Request;
|
||||
use think\facade\Db;
|
||||
use think\facade\Cache;
|
||||
use think\facade\Config;
|
||||
use app\common\model\Comment;
|
||||
use app\common\model\Article as ArticleModel;
|
||||
use think\exception\ValidateException;
|
||||
use think\facade\Config;
|
||||
use taoler\com\Message;
|
||||
use app\common\model\Cate;
|
||||
use app\common\model\User;
|
||||
@ -28,7 +28,31 @@ class Article extends BaseController
|
||||
//获取分类ID
|
||||
$ename = Request::param('ename');
|
||||
$type = Request::param('type');
|
||||
$page = Request::param('page');
|
||||
//分页伪静态
|
||||
$str = Request::baseUrl(); //不带参数在url
|
||||
$patterns = "/\d+/"; //数字正则
|
||||
preg_match($patterns,$str,$arr); //正则查询页码出现在位置
|
||||
//检测route配置中是否设置了伪静态后缀
|
||||
$suffix = Config::get('route.url_html_suffix') ? '.'.Config::get('route.url_html_suffix') : '/';
|
||||
if(Config::get('route.url_html_suffix')){
|
||||
//伪静态有后缀
|
||||
if(isset($arr[0])){
|
||||
$page = $arr[0];
|
||||
$url = strstr($str,$arr[0],true);
|
||||
} else {
|
||||
$page = 1;
|
||||
$url = strstr($str,'.html',true).'/';
|
||||
}
|
||||
} else {
|
||||
//伪静态后缀false
|
||||
if(isset($arr[0])){
|
||||
$page = $arr[0];
|
||||
$url = strstr($str,$arr[0],true);
|
||||
} else {
|
||||
$page = 1;
|
||||
$url = $str.'/';
|
||||
}
|
||||
}
|
||||
|
||||
$cateId = Db::name('cate')->where('ename',$ename)->value('id');
|
||||
if($cateId){
|
||||
@ -47,7 +71,12 @@ class Article extends BaseController
|
||||
'user' => function($query){
|
||||
$query->field('id,name,nickname,user_img,area_id,vip');
|
||||
}
|
||||
])->withCount(['comments'])->where(['status'=>1,'jie'=>1])->where($where)->order(['is_top'=>'desc','create_time'=>'desc'])->paginate(15);
|
||||
])->withCount(['comments'])->where(['status'=>1,'jie'=>1])->where($where)->order(['is_top'=>'desc','create_time'=>'desc'])
|
||||
->paginate([
|
||||
'list_rows' => 15,
|
||||
'page' => $page,
|
||||
'path' =>$url.'[PAGE]'.$suffix
|
||||
]);
|
||||
break;
|
||||
|
||||
case 'hot':
|
||||
@ -58,7 +87,12 @@ class Article extends BaseController
|
||||
'user' => function($query){
|
||||
$query->field('id,name,nickname,user_img,area_id,vip');
|
||||
}
|
||||
])->withCount(['comments'])->where('status',1)->where($where)->where('is_hot',1)->order(['is_top'=>'desc','create_time'=>'desc'])->paginate(15);
|
||||
])->withCount(['comments'])->where('status',1)->where($where)->where('is_hot',1)->order(['is_top'=>'desc','create_time'=>'desc'])
|
||||
->paginate([
|
||||
'list_rows' => 15,
|
||||
'page' => $page,
|
||||
'path' =>$url.'[PAGE]'.$suffix
|
||||
]);
|
||||
break;
|
||||
|
||||
case 'top':
|
||||
@ -69,7 +103,12 @@ class Article extends BaseController
|
||||
'user' => function($query){
|
||||
$query->field('id,name,nickname,user_img,area_id,vip');
|
||||
}
|
||||
])->withCount(['comments'])->where('status',1)->where($where)->where('is_top',1)->order(['is_top'=>'desc','create_time'=>'desc'])->paginate(15);
|
||||
])->withCount(['comments'])->where('status',1)->where($where)->where('is_top',1)->order(['is_top'=>'desc','create_time'=>'desc'])
|
||||
->paginate([
|
||||
'list_rows' => 15,
|
||||
'page' => $page,
|
||||
'path' =>$url.'[PAGE]'.$suffix
|
||||
]);
|
||||
break;
|
||||
|
||||
default:
|
||||
@ -80,8 +119,12 @@ class Article extends BaseController
|
||||
'user' => function($query){
|
||||
$query->field('id,name,nickname,user_img,area_id,vip');
|
||||
}
|
||||
])->withCount(['comments'])->where('status',1)->where($where)->order(['is_top'=>'desc','create_time'=>'desc'])->paginate(15);
|
||||
|
||||
])->withCount(['comments'])->where('status',1)->where($where)->order(['is_top'=>'desc','create_time'=>'desc'])
|
||||
->paginate([
|
||||
'list_rows' => 15,
|
||||
'page' => $page,
|
||||
'path' =>$url.'[PAGE]'.$suffix
|
||||
]);
|
||||
break;
|
||||
}
|
||||
Cache::set('arts'.$ename.$type.$page,$artList,600);
|
||||
|
@ -38,7 +38,7 @@ class Auth
|
||||
}
|
||||
|
||||
} else {
|
||||
//排除登录页和验证码被重定向
|
||||
//排除登录页和验证码及退出登录后被重定向
|
||||
if($controller !== 'Login' && !stristr($request->pathinfo(),"captcha.html") && $action !== 'logout')
|
||||
{
|
||||
//非登录重定向
|
||||
|
Loading…
Reference in New Issue
Block a user