<?php
$db = Typecho_Db::get();
$sql = $db->select()->from('table.comments')
->where('cid = ?',$this->cid)
->where('mail = ?', $this->remember('mail',true))
->limit(1);
$result = $db->fetchAll($sql);
if($this->user->hasLogin() || $result) {
$content = preg_replace("/\[hide\](.*?)\[\/hide\]/sm",'<div class="reply2view">$1</div>',$this->content);
}
else{
$content = preg_replace("/\[hide\](.*?)\[\/hide\]/sm",'<div class="reply2view">此处内容需要评论回复后方可阅读。</div>',$this->content);
}
echo $content
?>
将上面代码替换模板post.php中的
<?php $this->content(); ?>
在写文章需要隐藏部分内容时用以下写法
此处内容需要评论回复后(审核通过)方可阅读。
css参考样式
.reply2view {
background: #f6f5f3;
padding: 10px 10px 10px 20px;
margin: 5px 0;
}