失眠网,内容丰富有趣,生活中的好帮手!
失眠网 > php 评论插件 Typecho评论增强插件:TeComment(.09.07更新)

php 评论插件 Typecho评论增强插件:TeComment(.09.07更新)

时间:2022-07-03 00:00:46

相关推荐

php 评论插件 Typecho评论增强插件:TeComment(.09.07更新)

TeComment(.09.07更新)

Typecho 评论增强插件,可为Typecho评论增加评论工具栏、实现评论列表异步加载以及Ajax提交评论功能

插件地址:TeComment

1、安装插件下载插件后,确认插件文件夹名称为TeComment,

上传插件文件夹TeComment至网站目录usr/plugins/

进入后台,在导航 控制台 > 插件 页面,选择启用TeComment插件

2、使用插件

2.1、评论工具栏

安装好插件后,要想显示评论工具栏,需要修改当前所使用主题的comments.php文件:

在textarea标签后插入如下代码(可自行确定放置位置)<?php TeComment_Plugin::showTool();?>

2.2、使用评论列表异步加载或Ajax提交评论功能前提

在开启评论列表异步加载或Ajax提交评论功能前,需要修改当前所使用主题的functions.php文件:

若functions.php文件中添加或替换threadedComments函数为/**

* 重写评论显示函数

*/

function threadedComments($comments, $options){

$html = TeComment_Plugin::parseCommentHtml($comments, $options);

$children = '';

if ($comments->children) {

ob_start();

$comments->threadedComments();

$children = ob_get_contents();

ob_end_clean();

}

$html = str_replace('>{children}'.$children.'

echo $html;

}

2.3、评论列表异步加载功能

要开启‘评论异步加载’功能,在插件设置页面启用‘评论异步加载’后,还需要修改当前所使用主题的comments.php文件:

代码<?php $this->comments()->to($comments); ?>

<?php if ($comments->have()): ?>

<?php $comments->listComments(); ?>

<?php $comments->pageNav('« 前一页', '后一页 »'); ?>

修改为<?php if($this->options->plugin('TeComment')->commentAjaxLoad): ?>

<?php $this->comments()->to($comments); ?>

<?php if ($comments->have()): ?>

<?php $comments->listComments(); ?>

<?php $comments->pageNav('« 前一页', '后一页 »'); ?>

代码<?php $comments->cancelReply(); ?>

修改为<?php echo '

2.4、Ajax提交评论

要开启‘Ajax提交评论’功能,只需要在在插件设置页面启用‘Ajax提交评论’即可此功能兼容系统默认的反垃圾保护功能

2.5、评论模板

为了实现评论列表异步加载和Ajax提交评论功能,插件引入了评论模板,默认的评论模板为:

{authorAvatar}

{beforeAuthor}{afterAuthor}{commentStatus}

{beforeDate}{created}{afterDate}{replyLink}{content}{children}

可根据模板的需要自行设计评论模板,可用参数包括:{theId} 评论锚点ID

{commentClass} 评论列表样式

{authorAvatar} 评论用户头像

{authorName} 评论用户名称

{authorUrl} 评论用户主页

{authorUrl} 评论用户邮箱

{created} 评论发布时间,时间格式为后台设置的格式

{replyLink}回复评论的链接

{content} 评论内容

{children} 子评论

旧版

前段时间,有朋友在博客留言,提及评论时怎么贴图。 刚好自己闲逛时发现张戈博客评论框下面的工具栏,或许可以用用。但是其博客程序为wordpress,不能使用,那就自己动手写吧

先看效果图:

js效果部分参考了张戈博客中的代码

工具栏中,表情的功能基本上是拷贝自羽中漫步的Smilies插件,可在后台设置使用的表情包

使用方法:<?php TeComment_Plugin::showTool();?>

启用插件后,在comments.php文件的合适位置加上以上代码即可

如果觉得《php 评论插件 Typecho评论增强插件:TeComment(.09.07更新)》对你有帮助,请点赞、收藏,并留下你的观点哦!

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。