This commit is contained in:
zhao 2020-03-14 17:29:37 +08:00
parent 3461ee39e8
commit 434c27dbbd
6 changed files with 30 additions and 17 deletions

View File

@ -27,18 +27,18 @@ class Article extends BaseController
//获取分类ID
$ename = Request::param('ename');
$type = Request::param('type');
$cate = Db::name('cate')->where('ename',$ename)->find();
$page = Request::param('page');
if($cate){
$where = ['cate_id' => $cate['id']];
$cateId = Db::name('cate')->where('ename',$ename)->value('id');
if($cateId){
$where = ['cate_id' => $cateId];
}
$artList = Cache::get('arts'.$cate['id'].$type);
$artList = Cache::get('arts'.$ename.$type.$page);
if(!$artList){
switch ($type) {
//查询文章,15个分1页
case 'all':
case 'jie':
$artList = ArticleModel::field('id,title,cate_id,user_id,create_time,is_top,is_hot')->with([
'cate' => function($query){
$query->where('delete_time',0)->field('id,catename');
@ -46,7 +46,7 @@ class Article extends BaseController
'user' => function($query){
$query->field('id,name,nickname,user_img,area_id');
}
])->withCount(['comments'])->where('status',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(15);
break;
case 'hot':
@ -79,11 +79,11 @@ class Article extends BaseController
'user' => function($query){
$query->field('id,name,nickname,user_img,area_id');
}
])->withCount(['comments'])->where('status',1)->where($where)->order(['is_top'=>'desc','create_time'=>'desc'])->withCache(30)->paginate(15);
])->withCount(['comments'])->where('status',1)->where($where)->order(['is_top'=>'desc','create_time'=>'desc'])->paginate(15);
break;
}
Cache::set('arts'.$cate['id'].$type,$artList,600);
Cache::set('arts'.$ename.$type.$page,$artList,600);
}

View File

@ -14,7 +14,7 @@ return [
// 驱动方式
'type' => 'File',
// 缓存保存目录
'path' => '',
'path' => '../runtime/cache/',
// 缓存前缀
'prefix' => '',
// 缓存有效期 0表示永久缓存

View File

@ -1,8 +1,13 @@
<IfModule mod_rewrite.c>
Options +FollowSymlinks -Multiviews
RewriteEngine On
FileETag MTime Size
RewriteBase /
RewriteCond %{SERVER_PORT} !^443$
RewriteRule (.*) https://%{SERVER_NAME}/$1 [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php [L,E=PATH_INFO:$1]
</IfModule>

View File

@ -1,2 +1,8 @@
User-agent: *
Disallow:
Disallow: /admin/
Disallow: /index/user/
Disallow: /index/api/
Disallow: /index/login.html
Disallow: /index/reg.html
Disallow: /*?*

View File

@ -102,7 +102,7 @@
</ul>
<div style="text-align: center">
<div class="laypage-main">
<a href="{:url('article/cate')}" class="laypage-next">更多帖子</a>
<a href="{:url('article/cate',['ename'=>'all'])}" class="laypage-next">更多帖子</a>
</div>
</div>

View File

@ -1,10 +1,12 @@
<div class="fly-panel-title fly-filter">
<a href="{:url('article/cate',['ename' => $Request.param.ename ,'type' => 'all'])} " {if condition="$type eq 'all'" } class="layui-this" {/if} >综合</a>
<a href="{:url('article/cate',['ename' => $Request.param.ename ?:'all' ,'type' => ''])} " {if condition="$type eq ''" } class="layui-this" {/if} >综合</a>
<span class="fly-mid"></span>
<a href="{:url('article/cate',['ename' => $Request.param.ename ,'type' => 'hot'])} " {if condition="$type eq 'hot'" } class="layui-this" {/if} >热帖</a>
<a href="{:url('article/cate',['ename' => $Request.param.ename ?:'all','type' => 'jie'])} " {if condition="$type eq 'jie'" } class="layui-this" {/if} >已结</a>
<span class="fly-mid"></span>
<a href="{:url('article/cate',['ename' => $Request.param.ename ,'type' => 'top'])} " {if condition="$type eq 'top'" } class="layui-this" {/if} >精华</a>
<a href="{:url('article/cate',['ename' => $Request.param.ename ?:'all','type' => 'hot'])} " {if condition="$type eq 'hot'" } class="layui-this" {/if} >热帖</a>
<span class="fly-mid"></span>
<a href="{:url('article/cate',['ename' => $Request.param.ename ?:'all','type' => 'top'])} " {if condition="$type eq 'top'" } class="layui-this" {/if} >精华</a>
<!--span class="fly-filter-right layui-hide-xs">
<a href="" class="layui-this">按最新</a>