作者 sgj

comment plugin add

... ... @@ -26,7 +26,7 @@ class ArticleController extends HomeBaseController
$articleId = $this->request->param('id', 0, 'intval');
$categoryId = $this->request->param('cid', 0, 'intval');
$article = $postService->publishedArticle($articleId, $categoryId);
$article = $postService->publishedArticleJYHT($articleId, $categoryId);
if (empty($articleId)) {
abort(404, '文章不存在!');
... ...
... ... @@ -30,7 +30,7 @@ class PortalPostModel extends Model
*/
public function user()
{
return $this->belongsTo('UserModel', 'user_id')->setEagerlyType(1);
return $this->belongsTo('UserModel', 'author_id')->setEagerlyType(1);
}
/**
... ...
... ... @@ -34,7 +34,7 @@ class PostService
];
$join = [
['__USER__ u', 'a.user_id = u.id']
['__USER__ u', 'a.author_id = u.id']
];
$field = 'a.*,u.user_login,u.user_nickname,u.user_email';
... ... @@ -122,6 +122,45 @@ class PostService
return $article;
}
public function publishedArticleJYHT($postId, $categoryId = 0)
{
$portalPostModel = new PortalPostModel();
if (empty($categoryId)) {
$where = [
'post.post_type' => 1,
'post.published_time' => [['< time', time()], ['> time', 0]],
'post.post_status' => 1,
'post.delete_time' => 0,
'post.id' => $postId
];
$article = $portalPostModel->alias('post')->field('post.*')
->where($where)
->find();
} else {
$where = [
'post.post_type' => 1,
'post.published_time' => [['< time', time()], ['> time', 0]],
'post.post_status' => 1,
'post.delete_time' => 0,
'relation.category_id' => $categoryId,
'relation.post_id' => $postId
];
$join = [
['__PORTAL_CATEGORY_POST__ relation', 'post.id = relation.post_id']
];
$article = $portalPostModel->alias('post')->field('post.*')
->join($join)
->where($where)
->find();
}
return $article;
}
//上一篇文章
public function publishedPrevArticle($postId, $categoryId = 0)
... ...
... ... @@ -18,13 +18,44 @@
<div class="article_item">
<div class="article_title">{$article.post_title}</div>
<div class="article_info">
<text>{$article.user.user_nickname}</text>
<text>2018.08.21</text>
<text>{$article.user.user_login}</text>
<text>{:date('Y.m.d',$article.published_time)}</text>
</div>
<div>
{$article.post_content}
</div>
</div>
<php>
$after_content_hook_param=[
'object_id'=>$article['id'],
'table_name'=>'portal_post',
'object_title'=>$article['post_title'],
'user_id'=>$article['user_id'],
'url'=>cmf_url_encode('portal/Article/index',array('id'=>$article['id'],'cid'=>$category['id'])),
'object'=>$article
];
</php>
<hook name="after_content" param="after_content_hook_param"/>
<php>
$comment_hook_param=[
'object_id'=>$article['id'],
'table_name'=>'portal_post',
'full_name'=>'portal_post',
'object_title'=>$article['post_title'],
'url'=>cmf_url_encode('portal/Article/index',array('id'=>$article['id'],'cid'=>$category['id']))
];
$comment=hook_one('comment',$comment_hook_param);
</php>
<if condition="empty($comment) && cmf_get_current_admin_id()">
<div style="border: 1px dashed #ddd;min-height: 200px;padding-top: 50px;">
<div class="alert alert-warning" role="alert">
此区域这为评论区,请安装评论插件!<br>
<em>注:普通用户不会看到此提示!</em>
</div>
</div>
</if>
{$comment}
<div class="article_item">
<div>
<text class="content_title">最新活动</text>
... ... @@ -48,28 +79,6 @@
</div>
</div>
<!-- dibu-->
<div class="null_box"></div>
<div class="bottom_box">
<textarea placeholder="写评论..." maxlength="200"></textarea>
<div class="submit_btn">
<text class="iconfont icon-tijiao"></text>
<text>提交</text>
</div>
</div>
<!--弹窗-->
<div class="public_popup_box">
<text>您已签到成功!</text>
<text>恭喜您获得10个积分</text>
</div>
<script src="__TMPL__/public/assets/js/jquery-2.1.0.js"></script>
<script src="__TMPL__/public/assets/js/area.js"></script>
<script src="__TMPL__/public/assets/js/select.js"></script>
<script>
$('.public_popup_box').hide()
$('.submit_btn').click(function () {
$('.public_popup_box').show().delay(2000).hide(2)
})
</script>
</body>
</html>
\ No newline at end of file
... ...
... ... @@ -3,7 +3,7 @@ body, h1, h2, h3, h4, h5, h6, hr, p, blockquote, dl, dt, dd, ul, ol, li, pre, fo
padding: 0;
}
body,html{
overflow: hidden;
/* overflow: hidden;*/
}
body, button, input, select, textarea {
... ...