前言
方法非全部原创(不懂 PHP),我只写了部分 Js 代码,思路和部分代码来自由小王先森 (xwsir.cn)基于 Joe 主题开发的 Word 主题
教程开始
将下面这段代码插入评论区(请自行美化样式),一般放在提交评论的按钮前
<input type="checkbox" name="is-private" id="PrivateComments"><label for="PrivateComments" class="PrivateCommentsLable">
Joe 主题放在在 public\comment.php 下图位置前面
其他主题可以在 comment.php 搜索你主题提交评论按钮的汉字,并放入前方
插入 JS,将下面这段代码插入 comment.php 最下方
<script>document.addEventListener('DOMContentLoaded',()=>{var groupInfo='<?php echo $groupUserInfo ?>';if(groupInfo!='administrator'){$(".comment_operation").css("display","none")}var comments4Reception='<?php $this->options->Comments4Reception() ?>';if(!comments4Reception||comments4Reception=='off'){$(".comment_operation").css("display","none")}});$('.comment_btn_operation').click(function(){var type=$(this).data('type');var coid=$(this).data('coid');$('#comment_form_operation').append('<input type="hidden" name="type" value="'+type+'" />');$('#comment_form_operation').append('<input type="hidden" name="coid" value="'+coid+'" />');$('#comment_form_operation').submit()});document.getElementById('PrivateComments').addEventListener('click',function(){var commentField=document.getElementById('comment');if(document.getElementById('PrivateComments').checked){Qmsg.info('已开启密语');var currentValue=commentField.value;commentField.value='密语# '+currentValue;commentField.addEventListener('input',preventDeletingText)}else{Qmsg.info('已关闭密语');commentField.value=commentField.value.replace('密语# ','');commentField.removeEventListener('input',preventDeletingText)}});function preventDeletingText(){var commentField=document.getElementById('comment');if(!commentField.value.startsWith('密语# ')){commentField.value='密语# '+commentField.value.substring(3)}}</script>
修改评论输出语句(以 Joe 主题为例)
在 comment.php 找到(其他主题请找到对应的实现相关功能的代码并修改,不会可以再评论区留言)
评论之后请刷新界面即可复制代码
评论之后请刷新界面即可复制代码
修改文本输入框,给文本框添加 id=“comment”,
如果你的主题输入框已有 id 值,就将 js 中的’comment’修改为主题的 id 值
我来看看