summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--functions.php2
-rw-r--r--includes/comments.php8
2 files changed, 8 insertions, 2 deletions
diff --git a/functions.php b/functions.php
index 85b0afc..d8e80b0 100644
--- a/functions.php
+++ b/functions.php
@@ -35,6 +35,8 @@ function themeFields(Typecho_Widget_Helper_Layout $layout) {
$layout->addItem($excerpt);
$meta = new Typecho_Widget_Helper_Form_Element_Text('meta', NULL, NULL,_t('元信息'), _t('页面/文章内页会显示该页面的评论数和创建日期(元信息),如果你不需要,可以写一段文字来代替这些内容。'));
$layout->addItem($meta);
+ $commentShow = new Typecho_Widget_Helper_Form_Element_Select('commentShow',array('0'=>'显示','1'=>'隐藏'),'0','是否显示评论列表');
+ $layout->addItem($commentShow);
}
/**
diff --git a/includes/comments.php b/includes/comments.php
index 4a0baff..721c4cf 100644
--- a/includes/comments.php
+++ b/includes/comments.php
@@ -45,10 +45,11 @@ echo $commentClass;
<?php } ?>
<div class="comment">
<?php $this->comments()->to($comments); ?>
+ <?php if($this->fields->commentShow == 0)://如果显示评论列表 ?>
<h3 class="comment-title">
<?php $this->commentsNum(_t('暂无评论'), _t('仅有一条评论'), _t('已有 %d 条评论')); ?>
</h3>
- <?php if ($comments->have()): ?>
+ <?php if ($comments->have())://如果有评论 则显示 ?>
<div class="comment-container">
<?php $comments->listComments(array(
'before' => '<div class="comment-list">',
@@ -60,7 +61,10 @@ echo $commentClass;
<div class="comment-pagenav">
<?php $comments->pageNav('<i class="iconfont icon-chevron-left comment-pagenav-icon"></i>', '<i class="iconfont icon-chevron-right comment-pagenav-icon"></i>'); ?>
</div>
- <?php endif; ?>
+ <?php endif;//有无评论判断结束?>
+ <?php else: //如果不显示评论列表 ?>
+ <div class="comment-hidden">博主已关闭本页面的评论显示<?php if($this->allow('comment')): ?>,您评论后将不会看到您的评论内容<?php endif; ?></div>
+ <?php endif;//是否显示判断结束 ?>
<div class="comment-form">
<!-- 判断设置是否允许对当前文章进行评论 -->