Blog

typecho用代码添加回复可见功能
2021年4月28日/717阅读

回复可见代码

<!---回复可见--->
<?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
?>
<!---回复可见--->

回复可见css代码

<!---回复可见css--->
.reply2view {
    background-color:rgb(255,255,255,0.3);
    border-radius:5px;
    border:1px dashed #888888;
    padding:10px 10px 10px 40px;
    position:relative;
}
<!---回复可见css--->
[@hide][@/hide]

把@取消掉就是回复可见

评论