可能很多使用DISCUZ! X3.2平台朋友,发现一个问题就是发帖的标题被限制为80个字符。且也没办法修改长度,今天这里给大家介绍几个方法,希望对大家有帮助。这里默认修改为120字节
工具/原料
ftp工具
电脑
第一步:修改JS验证字符数文件
1、首先使用ftp工具 进入后台文件管理。
2、找到文件static/js/forum_post.js ,下载下来,打开编辑
3、找到: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) >80) { showError('您的标题超过80个字符的限制'); return false; }修改为: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) >120) { showError('您的标题超过120个字符的限制'); return false; }保存文件上传覆盖原文件
4、然后找到文件static/js/forum_post.js ,下载下来,打开编辑
5、然后继续找到: if(theform.message.value == '' || theform.subject.value == '') { s = '抱歉,您尚未输入标题或内容'; theform.message.focus(); } else if(mb_strlen(theform.subject.value) > 80) { s = '您的标题超过 80 个字符的限制'; theform.subject.focus(); }修改为:if(theform.message.value == '' && theform.subject.value == '') { s = '抱歉,您尚未输入标题或内容'; theform.message.focus(); } else if(mb_strlen(theform.subject.value) >120) { s = '您的标题超过120个字符的限制'; theform.subject.focus(); }保存文件上传覆盖原文件
第二步:数据库修改
1、首先,进入discuz的后台->站长->数据库->升级
2、由于Discuz! 后台默认情况下禁止 SQL 语句直接执行,只能使用常用 SQL 当中的内容。如果您想自己随意书写 SQL 升级语句,需要将 config/config_global.php 当中的 $_config[admincp][runquery] 设置修改为 1。(因为我们这里需要执行SQL语句所以需要改,或者直接在PHPmyadmin 里面执行SQL语句即可)这里我是修改了config_global.php文件。
3、数倌栗受绽据库修改,修改数据库标题字段的长度为120字符:运行下面的sql语句:(注意修改你的表的前缀)ALTER TABLE `pr髫潋啜缅e_forum_post` CHANGE `subject` `subject` VARCHAR(120) NOT NULL;ALTER TABLE `pre_forum_rsscache` CHANGE `subject` `subject` char(120) NOT NULL;ALTER TABLE `pre_forum_thread` CHANGE `subject` `subject` char(120) NOT NULL;(把次三行代码填入如图所示对话框)
4、点击:提交 ,成功如图所示
第三步:修改模板中写死的字符限制数
1、然后继续使用ftp工具找到,找到文件\template\default\forum\post_editor_extra.htm下载,编辑
2、找到:(把80 改成 120)争犸禀淫<!--{if $_GET[action] != 'reply'}--> <span><input type="text" name="subject" id="subject" class="px" value="$postinfo[subject]" {if $_GET[action] == 'newthread'}onblur="if($('tags')){relatekw('-1','-1'{if $_G['group']['allowposttag']},function(){extraCheck(4)}{/if});doane();}"{/if} onkeyup="strLenCalc(this, 'checklen', 80);" style="width: 25em" tabindex="1" /></span> <!--{else}--> <span id="subjecthide" class="z">RE: $thread[subject] [<a href="javascript:;" onclick="display('subjecthide');display('subjectbox');$('subject').value='RE: {echo dhtmlspecialchars(str_replace('\'', '\\\'', $thread[subject]))}';display('subjectchk');strLenCalc($('subject'), 'checklen', 80);return false;">{lang modify}</a>]</span> <span id="subjectbox" style="display:none"><input type="text" name="subject" id="subject" class="px" value="" onkeyup="strLenCalc(this, 'checklen', 80);" style="width: 25em" /></span> <!--{/if}--> <span id="subjectchk"{if $_GET[action] == 'reply'} style="display:none"{/if}>{lang comment_message1} <strong id="checklen">80</strong> {lang comment_message2}</span> <script type="text/javascript">strLenCalc($('subject'), 'checklen', 80)</script> <!--{/if}-->修改为:<!--{if $_GET[action] != 'reply'}--><span><input type="text" name="subject" id="subject" class="px" value="$postinfo[subject]" {if $_GET[action] == 'newthread'}onblur="if($('tags')){relatekw('-1','-1'{if $_G['group']['allowposttag']},function(){extraCheck(4)}{/if});doane();}"{/if}#ff0000">120);" style="width: 25em" tabindex="1" /></span><!--{else}--><span id="subjecthide" class="z">RE: $thread[subject] [<a href="javascript:;"#ff0000">120);return false;">{lang modify}</a>]</span><span id="subjectbox" style="display:none"><input type="text" name="subject" id="subject" class="px" value=""FONT-WEIGHT: bold; COLOR: #0000ff">120);" style="width: 25em" /></span><!--{/if}--><span id="subjectchk"{if $_GET[action] == 'reply'} style="display:none"{/if}>{lang comment_message1} <strong id="checklen">120</strong> {lang comment_message2}</span><script type="text/javascript">strLenCalc($('subject'), 'checklen',120)</script><!--{/if}-->保存文件上传覆盖原文件
3、继续找到文件\template\default\forum\forumdisplay_fastpost.htm下载,编辑
4、找到:<input type="text" id="subject" name="subject" class="px" value="" onkeyup="strLenCalc(this, 'checklen', 80);" tabindex="11" style="width: 25em" /> <span>{lang comment_message1} <strong id="checklen">80</strong> {lang comment_message2}</span>修改为:<input type="text" id="subject" name="subject" class="px" value="" onkeyup="strLenCalc(this, 'checklen', 120);" tabindex="11" style="width: 25em" /> <span>{lang comment_message1} <strong id="checklen">120</strong> {lang comment_message2}</span>保存文件上传覆盖原文件
第四步:修改函数验证文件
1、继续使用ftp工具 。找到文件/source/function/function_post.php下载编辑。
2、找到:if(dstrlen($subject) >80) {return 'post_subject_toolong';}修改为:if(dstrlen($subject) >120) {return 'post_subject_toolong';}保存文件上传覆盖原文件
第五步:修改语言包文件
1、找到: source/language/lang_messege.php 下载编辑
2、找到:'post_subject_toolong' => '抱歉,您的标题超过 80 个字符修改标题长度'修改:'post_subject_toolong' => '抱歉,您的标题超过 120个字符修改标题长度'
3、最后进入discuz的后台->工具->更新缓存
4、然后我们看看。现在效果如何: