可能很多使用DISCUZ! X3.4平臺(tái)朋友,發(fā)現(xiàn)一個(gè)問題就是發(fā)帖的標(biāo)題被限制為80個(gè)字符。且也沒辦法修改長(zhǎng)度,今天這里給大家介
紹幾個(gè)方法,希望對(duì)大家有幫助。
字符最大限制為255,不要修改超過255,不然會(huì)失敗!
不管修改什么文件,首先要做的就是備份好要修改的文件,這是一個(gè)稱職站長(zhǎng)必做的一件事情
摘要:現(xiàn)在修改不像以前那樣更新就可以直接使用了,更新之后還要等待5-10分鐘,這是必須等待的。
心愿:如果此貼對(duì)您有用的話麻煩您動(dòng)一動(dòng)鼠標(biāo)給個(gè)免費(fèi)的評(píng)分吧!謝謝爸爸們!
第一步:進(jìn)入后臺(tái)文件管理。
找到文件 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('抱歉,您尚未輸入標(biāo)題或內(nèi)容');</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('您的標(biāo)題超過 80 個(gè)字符的限制');</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>
復(fù)制代碼
修改為:
- <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('抱歉,您尚未輸入標(biāo)題或內(nèi)容');</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('您的標(biāo)題超過 255 個(gè)字符的限制');</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>
復(fù)制代碼
然后找到文件 static/js/forum.js 編輯
然后繼續(xù)找到:
- <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 = '抱歉,您尚未輸入標(biāo)題或內(nèi)容';</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 = '您的標(biāo)題超過 80 個(gè)字符的限制';</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>
復(fù)制代碼
修改為:
- <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 = '抱歉,您尚未輸入標(biāo)題或內(nèi)容';</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 = '您的標(biāo)題超過 255 個(gè)字符的限制';</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>
復(fù)制代碼
第二步:數(shù)據(jù)庫(kù)修改
進(jìn)入discuz的后臺(tái)->站長(zhǎng)->數(shù)據(jù)庫(kù)->升級(jí)
由于Discuz! 后臺(tái)默認(rèn)情況下禁止 SQL 語(yǔ)句直接執(zhí)行,只能使用常用 SQL 當(dāng)中的內(nèi)容。
如果您想自己隨意書寫 SQL 升級(jí)語(yǔ)句,需要將 config/config_global.php 當(dāng)中的
- $_config['admincp']['runquery'] = '0';
復(fù)制代碼
把 0 設(shè)置修改為 1
。
(因?yàn)槲覀冞@里需要執(zhí)行SQL語(yǔ)句所以需要改,或者直接在PHPmyadmin 里面執(zhí)行SQL語(yǔ)句即可)
這里我是修改了 config_global.php 文件。
3
數(shù)據(jù)庫(kù)修改,修改數(shù)據(jù)庫(kù)標(biāo)題字段的長(zhǎng)度為255字符:運(yùn)行下面的sql語(yǔ)句:(注意修改你的表的前綴)
- <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>
復(fù)制代碼
點(diǎn)擊:提交 ,成功如圖所示
01.png (34.37 KB, 下載次數(shù): 60)
下載附件
2019-7-29 00:06 上傳
第三步:修改模板中寫死的字符限制數(shù)
找到文件 \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>
復(fù)制代碼
修改為:
- <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>
復(fù)制代碼
繼續(xù)找到文件 \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>
復(fù)制代碼
修改為:
- <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>
復(fù)制代碼
保存文件上傳覆蓋原文件
第四步:修改函數(shù)驗(yàn)證文件
找到文件 /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>
復(fù)制代碼
修改為:
- <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>
復(fù)制代碼
保存文件上傳覆蓋原文件
第五步:修改語(yǔ)言包文件
找到: source/language/lang_messege.php 下載編輯
找到:
- 'post_subject_toolong' => '抱歉,您的標(biāo)題超過 80 個(gè)字符修改標(biāo)題長(zhǎng)度',
復(fù)制代碼
修改:
- 'post_subject_toolong' => '抱歉,您的標(biāo)題超過 255 個(gè)字符修改標(biāo)題長(zhǎng)度',
復(fù)制代碼
最后進(jìn)入discuz的后臺(tái)->工具->更新緩存 之后完畢,耐心等待!