typecho 在評論時默認是沒有 @
評論人的功能,可以用代碼加一下。
在 functions.php
中:
/*
* 評論回覆時 @ 評論人
*/
function get_comment_at($coid)
{
$db = Typecho_Db::get();
$prow = $db->fetchRow($db->select('parent,status')->from('table.comments')
->where('coid = ?', $coid));
$mail = "";
$parent = @$prow['parent'];
if ($parent != "0") {
$arow = $db->fetchRow($db->select('author,status,mail')->from('table.comments')
->where('coid = ?', $parent));
@$author = @$arow['author'];
$mail = @$arow['mail'];
if(@$author && $arow['status'] == "approved"){
if (@$prow['status'] == "waiting"){
echo '<p class="commentReview">(評論審核中))</p>';
}
echo '<a href="#comment-' . $parent . '">@' . $author . '</a>';
}else{
if (@$prow['status'] == "waiting"){
echo '<p class="commentReview">(評論審核中))</p>';
}else{
echo '';
}
}
} else {
if (@$prow['status'] == "waiting"){
echo '<p class="commentReview">(評論審核中))</p>';
}else{
echo '';
}
}
}
然後在 comments.php
中輸出評論內容代碼的前面加上:
<?php $parentMail = get_comment_at($comments->coid)?><?php echo $parentMail;?>
▼代碼所示
▼效果圖
我的部落格即將同步至騰訊雲 + 社區,邀請大家一同入駐:https://cloud.tencent.com/developer/support-plan?invite_code=17ctk6evsjk5b