新增置顶文章

This commit is contained in:
augushong
2020-04-21 10:01:09 +08:00
parent 3a8fd0b7d7
commit 07006ecb4e
4 changed files with 47 additions and 4 deletions

View File

@@ -4,6 +4,7 @@ namespace app\index\controller;
use app\model\Category; use app\model\Category;
use app\model\Nav; use app\model\Nav;
use app\model\Post;
use think\facade\View; use think\facade\View;
use think\helper\Str; use think\helper\Str;
@@ -50,5 +51,9 @@ class Common extends BaseController
$this->assign('list_category_first_level', $list_category_first_level); $this->assign('list_category_first_level', $list_category_first_level);
$list_nav_more = Nav::where('type', 8)->order('sort asc')->where('status', 1)->select(); $list_nav_more = Nav::where('type', 8)->order('sort asc')->where('status', 1)->select();
View::assign('list_nav_more', $list_nav_more); View::assign('list_nav_more', $list_nav_more);
$top_posts = Post::where('is_top',1)->limit(8)->select();
$this->assign('top_posts',$top_posts);
} }
} }

View File

@@ -91,7 +91,7 @@
} }
.post-item{ .post-item,.plus-post-item{
display: flex; display: flex;
justify-content: flex-start; justify-content: flex-start;
align-items: center; align-items: center;
@@ -100,7 +100,7 @@
border-bottom: 1px solid #ddd; border-bottom: 1px solid #ddd;
} }
.post-item .poster{ .post-item .poster,.plus-post-item .poster{
width: 160px; width: 160px;
height: 100px; height: 100px;
background-size: cover; background-size: cover;
@@ -109,6 +109,15 @@
margin-right: 15px; margin-right: 15px;
} }
.plus-post-item .poster{
width: 60px;
height: 60px;
}
.plus-post-item .title{
font-size: 14px;
}
.post-item .info .title{ .post-item .info .title{
font-size: 22px; font-size: 22px;
font-weight: 600; font-weight: 600;

View File

@@ -48,12 +48,12 @@
<div> <div>
<input type="radio" name="index_tpl_name" value="articles_" title="资讯头条主题-'articles_'"> <input type="radio" name="index_tpl_name" value="articles_" title="资讯头条主题-'articles_'">
</div> </div>
<div> <!-- <div>
<input type="radio" name="index_tpl_name" value="documents_" title="文档主题-'documents_'"> <input type="radio" name="index_tpl_name" value="documents_" title="文档主题-'documents_'">
</div> </div>
<div> <div>
<input type="radio" name="index_tpl_name" value="blog_" title="博客主题-'blog_'"> <input type="radio" name="index_tpl_name" value="blog_" title="博客主题-'blog_'">
</div> </div> -->
</div> </div>
</div> </div>

View File

@@ -12,6 +12,35 @@
</div> </div>
</form> </form>
</div> </div>
<div class="session border">
<div class="header">
推荐阅读
</div>
<div class="body">
<div class="plus-post-list">
{volist name='top_posts' id='post'}
<a href="{:url('Post/read',['id'=>$post.id])}" class="plus-post-item"
onmouseover="$(this).find('.poster').addClass('layui-anim-scale')"
onmouseout="$(this).find('.poster').removeClass('layui-anim-scale')">
{notempty name='$post->getData("poster")'}
<div class="poster layui-anim" style="background-image: url('{$post.poster}');"></div>
{/notempty}
<div class="info">
<div class="title">{$post.title}</div>
</div>
</a>
{/volist}
</div>
</div>
</div>
<div class="session border"> <div class="session border">
<div class="header"> <div class="header">
更多 更多