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;?>
▼代码所示
▼效果图
扫码关注腾讯云开发者
领取腾讯云代金券
Copyright © 2013 - 2025 Tencent Cloud. All Rights Reserved. 腾讯云 版权所有
深圳市腾讯计算机系统有限公司 ICP备案/许可证号:粤B2-20090059 深公网安备号 44030502008569
腾讯云计算(北京)有限责任公司 京ICP证150476号 | 京ICP备11018762号 | 京公网安备号11010802020287
Copyright © 2013 - 2025 Tencent Cloud.
All Rights Reserved. 腾讯云 版权所有