可能很多使用DISCUZ! X3.4平臺朋友,發現一個問題就是發帖的標題被限制為80個字符。且也沒辦法修改長度,今天這里給大家介
紹幾個方法,希望對大家有幫助。
字符最大限制為255,不要修改超過255,不然會失敗!
不管修改什么文件,首先要做的就是備份好要修改的文件,這是一個稱職站長必做的一件事情
摘要:現在修改不像以前那樣更新就可以直接使用了,更新之后還要等待5-10分鐘,這是必須等待的。
心愿:如果此貼對您有用的話麻煩您動一動鼠標給個免費的評分吧!謝謝爸爸們!
第一步:進入后臺文件管理。
找到文件 static/js/forum_post.js 編輯
找到:
- <div align="left"><font size="3"><span style="white-space:pre"> </span>if(($('postsubmit').name != 'replysubmit' && !($('postsubmit').name == 'editsubmit' && !isfirstpost) && </font></div><div align="left"><font size="3">
- </font></div><div align="left"><font size="3">theform.subject.value == "") || !sortid && !special && trim(message) == "") {</font></div><div align="left"><font size="3"><span style="white-space:pre"> </span>showError('抱歉,您尚未輸入標題或內容');</font></div><div align="left"><font size="3"><span style="white-space:pre"> </span>return false;</font></div><div align="left"><font size="3"><span style="white-space:pre"> </span>} else if(mb_strlen(theform.subject.value) > 80) {</font></div><div align="left"><font size="3"><span style="white-space:pre"> </span>showError('您的標題超過 80 個字符的限制');</font></div><div align="left"><font size="3"><span style="white-space:pre"> </span>return false;</font></div><div align="left"><font size="3"><span style="white-space:pre"> </span>}</font></div>
復制代碼
修改為:
- <div align="left"><font size="3"><span style="white-space:pre"> </span>if(($('postsubmit').name != 'replysubmit' && !($('postsubmit').name == 'editsubmit' && !isfirstpost) && </font></div><div align="left"><font size="3">
- </font></div><div align="left"><font size="3">theform.subject.value == "") || !sortid && !special && trim(message) == "") {</font></div><div align="left"><font size="3"><span style="white-space:pre"> </span>showError('抱歉,您尚未輸入標題或內容');</font></div><div align="left"><font size="3"><span style="white-space:pre"> </span>return false;</font></div><div align="left"><font size="3"><span style="white-space:pre"> </span>} else if(mb_strlen(theform.subject.value) > 255) {</font></div><div align="left"><font size="3"><span style="white-space:pre"> </span>showError('您的標題超過 255 個字符的限制');</font></div><div align="left"><font size="3"><span style="white-space:pre"> </span>return false;</font></div><div align="left"><font size="3"><span style="white-space:pre"> </span>}</font></div>
復制代碼
然后找到文件 static/js/forum.js 編輯
然后繼續找到:
- <div align="left"><font size="3"><span style="white-space:pre"> </span>if(theform.message.value == '' || theform.subject.value == '') {</font></div><div align="left"><font size="3"><span style="white-space:pre"> </span>s = '抱歉,您尚未輸入標題或內容';</font></div><div align="left"><font size="3"><span style="white-space:pre"> </span>theform.message.focus();</font></div><div align="left"><font size="3"><span style="white-space:pre"> </span>} else if(mb_strlen(theform.subject.value) > 80) {</font></div><div align="left"><font size="3"><span style="white-space:pre"> </span>s = '您的標題超過 80 個字符的限制';</font></div><div align="left"><font size="3"><span style="white-space:pre"> </span>theform.subject.focus();</font></div><div align="left"><font size="3"><span style="white-space:pre"> </span>}</font></div>
復制代碼
修改為:
- <div align="left"><font size="3"><span style="white-space:pre"> </span>if(theform.message.value == '' || theform.subject.value == '') {</font></div><div align="left"><font size="3"><span style="white-space:pre"> </span>s = '抱歉,您尚未輸入標題或內容';</font></div><div align="left"><font size="3"><span style="white-space:pre"> </span>theform.message.focus();</font></div><div align="left"><font size="3"><span style="white-space:pre"> </span>} else if(mb_strlen(theform.subject.value) > 255) {</font></div><div align="left"><font size="3"><span style="white-space:pre"> </span>s = '您的標題超過 255 個字符的限制';</font></div><div align="left"><font size="3"><span style="white-space:pre"> </span>theform.subject.focus();</font></div><div align="left"><font size="3"><span style="white-space:pre"> </span>}</font></div>
復制代碼
第二步:數據庫修改
進入discuz的后臺->站長->數據庫->升級
由于Discuz! 后臺默認情況下禁止 SQL 語句直接執行,只能使用常用 SQL 當中的內容。
如果您想自己隨意書寫 SQL 升級語句,需要將 config/config_global.php 當中的
- $_config['admincp']['runquery'] = '0';
復制代碼
把 0 設置修改為 1
。
(因為我們這里需要執行SQL語句所以需要改,或者直接在PHPmyadmin 里面執行SQL語句即可)
這里我是修改了 config_global.php 文件。
3
數據庫修改,修改數據庫標題字段的長度為255字符:運行下面的sql語句:(注意修改你的表的前綴)
- <div align="left"><font size="3">ALTER TABLE `pre_forum_post` CHANGE `subject` `subject` VARCHAR(255) NOT NULL;</font></div><div align="left"><font size="3">ALTER TABLE `pre_forum_rsscache` CHANGE `subject` `subject` char(255) NOT NULL;</font></div><div align="left"><font size="3">ALTER TABLE `pre_forum_thread` CHANGE `subject` `subject` char(255) NOT NULL;</font></div>
復制代碼
點擊:提交 ,成功如圖所示
01.png (34.37 KB, 下載次數: 51)
下載附件
2019-7-29 00:06 上傳
第三步:修改模板中寫死的字符限制數
找到文件 \template\default\forum\post_editor_extra.htm 編輯
找到:(把80 改成 255)
- <div align="left"><font size="3">
- </font></div><div align="left"><font size="3"><span style="white-space:pre"> </span><!--{if $_GET[action] != 'reply'}--></font></div><div align="left"><font size="3"><span style="white-space:pre"> </span><span><input type="text" name="subject" id="subject" class="px" value="$postinfo[subject]" onkeyup="strLenCalc(this, 'checklen', 80);" style="width: 25em" tabindex="1" /></span></font></div><div align="left"><font size="3"><span style="white-space:pre"> </span><!--{else}--></font></div><div align="left"><font size="3"><span style="white-space:pre"> </span><span id="subjecthide" class="z">RE: $thread[subject] [<a href="javascript:;" onclick="display('subjecthide');display('subjectbox');return false;">{lang modify}</a>]</span></font></div><div align="left"><font size="3"><span style="white-space:pre"> </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></font></div><div align="left"><font size="3"><span style="white-space:pre"> </span><!--{/if}--><span style="white-space:pre"> </span></font></div><div align="left"><font size="3"><span style="white-space:pre"> </span><span id="subjectchk"{if $_GET[action] == 'reply'} style="display:none"{/if}>{lang comment_message1} <strong id="checklen">80</strong> {lang comment_message2}</span></font></div><div align="left"><font size="3"><span style="white-space:pre"> </span><script type="text/javascript">strLenCalc($('subject'), 'checklen', 80)</script></font></div>
復制代碼
修改為:
- <div align="left"><font size="3"><span style="white-space:pre"> </span><!--{if $_GET[action] != 'reply'}--></font></div><div align="left"><font size="3"><span style="white-space:pre"> </span><span><input type="text" name="subject" id="subject" class="px" value="$postinfo[subject]" onkeyup="strLenCalc(this, 'checklen', 255);" style="width: 25em" tabindex="1" /></span></font></div><div align="left"><font size="3"><span style="white-space:pre"> </span><!--{else}--></font></div><div align="left"><font size="3"><span style="white-space:pre"> </span><span id="subjecthide" class="z">RE: $thread[subject] [<a href="javascript:;" onclick="display('subjecthide');display('subjectbox');return false;">{lang modify}</a>]</span></font></div><div align="left"><font size="3"><span style="white-space:pre"> </span><span id="subjectbox" style="display:none"><input type="text" name="subject" id="subject" class="px" value="" onkeyup="strLenCalc(this, 'checklen', 255);" style="width: 25em" /></span></font></div><div align="left"><font size="3"><span style="white-space:pre"> </span><!--{/if}--><span style="white-space:pre"> </span></font></div><div align="left"><font size="3"><span style="white-space:pre"> </span><span id="subjectchk"{if $_GET[action] == 'reply'} style="display:none"{/if}>{lang comment_message1} <strong id="checklen">255</strong> {lang comment_message2}</span></font></div><div align="left"><font size="3"><span style="white-space:pre"> </span><script type="text/javascript">strLenCalc($('subject'), 'checklen', 255)</script></font></div>
復制代碼
繼續找到文件 \template\default\forum\forumdisplay_fastpost.htm 編輯
找到:
- <div align="left"><font size="3"><span style="white-space:pre"> </span><!--{/if}--></font></div><div align="left"><font size="3"><span style="white-space:pre"> </span><input type="text" id="subject" name="subject" class="px" value="" onkeyup="strLenCalc(this, 'checklen', 80);" tabindex="11" style="width: 25em" /></font></div><div align="left"><font size="3"><span style="white-space:pre"> </span><span>{lang comment_message1} <strong id="checklen">80</strong> {lang comment_message2}</span></font></div><div align="left"><font size="3"><span style="white-space:pre"> </span></div></font></div>
復制代碼
修改為:
- <div align="left"><font size="3"><span style="white-space:pre"> </span><!--{/if}--></font></div><div align="left"><font size="3"><span style="white-space:pre"> </span><input type="text" id="subject" name="subject" class="px" value="" onkeyup="strLenCalc(this, 'checklen', 255);" tabindex="11" style="width: 25em" /></font></div><div align="left"><font size="3"><span style="white-space:pre"> </span><span>{lang comment_message1} <strong id="checklen">255</strong> {lang comment_message2}</span></font></div><div align="left"><font size="3"><span style="white-space:pre"> </span></div></font></div>
復制代碼
保存文件上傳覆蓋原文件
第四步:修改函數驗證文件
找到文件 /source/function/function_post.php 編輯
找到:
- <div align="left"><font size="3"><span style="white-space:pre"> </span>if(dstrlen($subject) > 80) {</font></div><div align="left"><font size="3"><span style="white-space:pre"> </span>return 'post_subject_toolong';</font></div><div align="left"><font size="3"><span style="white-space:pre"> </span>}</font></div>
復制代碼
修改為:
- <div align="left"><font size="3"><span style="white-space:pre"> </span>if(dstrlen($subject) > 255) {</font></div><div align="left"><font size="3"><span style="white-space:pre"> </span>return 'post_subject_toolong';</font></div><div align="left"><font size="3"><span style="white-space:pre"> </span>}</font></div>
復制代碼
保存文件上傳覆蓋原文件
第五步:修改語言包文件
找到: source/language/lang_messege.php 下載編輯
找到:
- 'post_subject_toolong' => '抱歉,您的標題超過 80 個字符修改標題長度',
復制代碼
修改:
- 'post_subject_toolong' => '抱歉,您的標題超過 255 個字符修改標題長度',
復制代碼
最后進入discuz的后臺->工具->更新緩存 之后完畢,耐心等待!