菜心哥 发表于 2023-8-30 23:50:29

Discuz修改论坛默认发帖标题80个字符限制教程

discuz默认标题只能输入80个字符,是不是发现经常不够用,网上搜到的修改教程还是说的不够详细,这里我亲自尝试修改成功了,下面把详细过程记录下来分享给大家,我觉得改成180字符长度肯定足够了。当然,你也可以根据自己的实际需求来决定字符的长度。
1、首先要修改数据库,需要修改/config/config_global.php里面的
$_config['admincp']['runquery'] = '1';把“0”改成“1”,为什么要改成“1”?因为需要执行SQl语句,除了我们使用像phpmyadmin这样的MySQl调试工具之外,Discuz自身也是可以执行SQL语句功能的。你先打开后台——》站长——》数据库——》升级




还可以看到详细提示信息,其实还没有直接执行SQL语句的编辑框,你通过修改后再打开后台——》站长——》数据库——》升级,如图:




可以看到直接执行SQL语句的编辑框了,然后分别运行下面的3条sql语句:ALTER TABLE `pre_forum_post` CHANGE `subject` `subject` VARCHAR(180) NOT NULL;ALTER TABLE `pre_forum_rsscache` CHANGE `subject` `subject` char(180) NOT NULL;ALTER TABLE `pre_forum_thread` CHANGE `subject` `subject` char(180) NOT NULL;
2、找到文件sitatic/js/forum.js
if(theform.message.value == '' && theform.subject.value == '') {                s = '抱歉,您尚未输入标题或内容';                theform.message.focus();      } else if(mb_strlen(theform.subject.value) > 80) {                s = '您的标题超过 80 个字符的限制';                theform.subject.focus();      }将里边的80字符改为180字符
3、接着修改JS验证字符数:修改文件static/js/forum_post.js中的(可以Ctrl+F搜索字段)
if(($('postsubmit').name != 'replysubmit' && !($('postsubmit').name == 'editsubmit' && !isfirstpost) && theform.subject.value == "") || !sortid && !special && trim(message) == "") {
                showError('抱歉,您尚未输入标题或内容');
                return false;
      } else if(mb_strlen(theform.subject.value) > 180) {
                showError('您的标题超过 180 个字符的限制');
                return false;
      }
将里边的80字符改为180字符
4、修改模板中写死的字符限制数:    找到文件\template\default\forum\post_editor_extra.htm中的80字符限制,修改为180(可以Ctrl+F搜索字段):
<!--{if $_GET != 'reply'}-->
                              <span><input type="text" name="subject" id="subject" class="px" value="$postinfo" style="width: 25em" tabindex="1" /></span>
                        <!--{else}-->
                              <span id="subjecthide" class="z">RE: $thread [<a href="javascript:;">{lang modify}</a>]</span>
                              <span id="subjectbox" style="display:none"><input type="text" name="subject" id="subject" class="px" value="" style="width: 25em" /></span>
                        <!--{/if}-->                        
                        <span id="subjectchk"{if $_GET == 'reply'} style="display:none"{/if}>{lang comment_message1} <strong id="checklen">180</strong> {lang comment_message2}</span>
                        <script type="text/javascript">strLenCalc($('subject'), 'checklen', 180)</script>将里边的80字符改为180字符,如上
5、找到文件\template\default\forum\forumdisplay_fastpost.htm
<input type="text" id="subject" name="subject" class="px" value="" tabindex="11" style="width: 25em" />
<span>{lang comment_message1} <strong id="checklen">180</strong> {lang comment_message2}</span>
将里边的80字符改为180字符,如上
6、修改函数验证提示:找到文件source/function/function_post.phpif(dstrlen($subject) > 180) {
return 'post_subject_toolong';

}将里边的80字符改为180字符,如上7、找到语言包提示文字,打开 source/language/lang_messege.php
'post_subject_toolong' => '抱歉,您的标题超过 180 个字符修改标题长度',更新下缓存,好了,到现在你的论坛发帖标题就修改为180个字符了,完全够用了!


页: [1]
查看完整版本: Discuz修改论坛默认发帖标题80个字符限制教程