社区首页
帖子列表代码:
#postPage(pageSize=20)
#for(post : clubPage.list)
<div class="card club-card">
<div class="row align-items-center h-full">
<div class="col-1 col-md-1 club-view">
<span>#(post.view_count ?? 0)</span>
<p>浏览</p>
</div>
<div class="col-1 col-md-1 club-answer">
<span>#(post.comment_count ?? 0)</span>
<p>回答</p>
</div>
<div class="col-10 col-md-10">
<div class="card-block">
<p>
<small>#(post.user.nickname ??)
#userMembers(post.user.id)
#for(member : members)
<a href="#(member.type.link ??)" class="label-vip2">
<img src="#(member.type.icon ??)" alt="#(member.type.title ??)">
</a>
#end
#end
/ <span class="elegantDate" data-elegant-date="#date(post.created,'yyyy-MM-dd HH:mm:ss')"></span>发布</small>
</p>
<h4 class="card-title"><a href="#(post.url ??)" style="color: #(post.title_color ??)"> #(post.title ??) </a>
<a href="#(post.category.url ??)" class="club-label">#(post.category.title ??)</a>
</h4>
</div>
</div>
</div>
</div>
#end
#end
备注:
#postPage(pageSize=20) —— 一个页面显示20条帖子
#(post.view_count ?? 0) —— 帖子浏览量
#(post.comment_count ?? 0) —— 帖子评论量
data-elegant-date="#date(post.created,'yyyy-MM-dd HH:mm:ss') —— 帖子发布时间
#(post.title ??) —— 帖子标题
#(post.url ??) —— 帖子链接
#(post.category.title ??) —— 帖子所属分类名称
#(post.category.url ??) —— 忒自所属分类链接
效果:
帖子分页代码:
#postPaginate(previousText="←",nextText="→")
<nav>
<ul class="pagination justify-content-center">
#for(page : pages)
<li class="page-item #(page.style)"><a class="page-link" href="#(page.url ??)">#(page.text ??)</a></li>
#end
</ul>
</nav>
#end
分页效果:
置顶帖子代码:
#topPosts()
#for(post : posts)
<div class="card club-card">
<div class="row align-items-center h-full">
<div class="col-1 col-md-1 club-view">
<span>#(post.view_count ?? 0)</span>
<p>浏览</p>
</div>
<div class="col-1 col-md-1 club-answer">
<span>#(post.comment_count ?? 0)</span>
<p>回答</p>
</div>
<div class="col-10 col-md-10">
<div class="card-block">
<p>
<small>#(post.user.nickname ??)
#userMembers(post.user.id)
#for(member : members)
<a href="#(member.type.link ??)" class="label-vip2">
<img src="#(member.type.icon ??)" alt="#(member.type.title ??)">
</a>
#end
#end
/ <span class="elegantDate" data-elegant-date="#date(post.created,'yyyy-MM-dd HH:mm:ss')"></span>发布</small>
</p>
<h4 class="card-title"> [置顶] <a href="#(post.url)" style="color: #(post.title_color ??)">#(post.title ??) </a>
<a href="#(post.category.url)" class="club-label">#(post.category.title ??)</a>
</h4>
</div>
</div>
</div>
</div>
#end
#end
置顶帖子效果
帖子分类tab代码:
<div class="club-title">
<ul class="nav nav-tabs-minimal club-tab">
<li class="nav-item">
<a class="nav-link #(clubCategory ? '' : 'active')" href="#(CPATH)/club">最新帖子</a>
</li>
#for(c : clubCategories)
<li class="nav-item">
<a class="nav-link #(c == clubCategory ? 'active' : '')" href="#(c.url)">#(c.title ??)</a>
</li>
#end
</ul>
<a class="btn btn-twitter btn-post" href="#(CPATH)/club/newpost">发帖</a>
</div>
帖子分类效果图: