修改post.php
<?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(); ?>
在functions.php中加入如下代码即可(解决缩略内容和feed暴露问题)
Typecho_Plugin::factory('Widget_Abstract_Contents')->excerptEx = array('myyodux','one');
Typecho_Plugin::factory('Widget_Abstract_Contents')->contentEx = array('myyodux','one');
class myyodux {
public static function one($con, $obj)
{
if(!$obj->is('single')){
$con = preg_replace("/\[hide\](.*?)\[\/hide\]/sm",'',$con);
}
return $con;
}
}
使用方法:
[hide]要隐藏的内容[/hide]
CSS参考样式:
.reply2view {
background:#f8f8f8;
padding:10px 10px 10px 40px;
position:relative
}