久久久久av_欧美日韩一区二区在线_国产精品三区四区_日韩中字在线

Discuz! 官方交流社區

標題: Discuz! X3.4論壇標題字數突破80的限制解決方法 [打印本頁]

作者: 我是小站長    時間: 2019-6-5 15:15
標題: Discuz! X3.4論壇標題字數突破80的限制解決方法
本帖最后由 我是小站長 于 2019-6-5 15:15 編輯

在玩論壇的站長朋友,每次發文章標題都受字數的限制,一直找不到解決的辦法,此教程為云墨親自測試的經驗總結,今天就分享給大家。
下面由源碼專家技術分享解決標題限制80字符方法步驟:

一、數據庫修改;
二、修改JS驗證字符數文件;
三、修改模板中寫死的字符限制數;
四,修改函數驗證文件;
五,修改語言包文件。
一、數據庫修改,修改數據庫標題字段的長度為200字符:運行下面的sql語句:
(注意修改你的表的前綴)
  1. ALTER TABLE `pre_forum_post` CHANGE `subject` `subject` VARCHAR(200) NOT NULL;
  2. ALTER TABLE `pre_forum_rsscache` CHANGE `subject` `subject` char(200) NOT NULL;
  3. ALTER TABLE `pre_forum_thread` CHANGE `subject` `subject` char(200) NOT NULL;
復制代碼

二、修改JS驗證字符數:
1、找到文件static/js/forum_post.js的75-81行
  1. if(($('postsubmit').name != 'replysubmit' && !($('postsubmit').name == 'editsubmit' && !isfirstpost) && theform.subject.value == "") || !sortid && !special && trim(message) == "") {
  2.                 showError('抱歉,您尚未輸入標題或內容');
  3.                 return false;
  4.         } else if(mb_strlen(theform.subject.value) > 80) {
  5.                 showError('您的標題超過 80 個字符的限制');
  6.                 return false;
  7.         }
復制代碼
修改為:
  1. if(($('postsubmit').name != 'replysubmit' && !($('postsubmit').name == 'editsubmit' && !isfirstpost) && theform.subject.value == "") || !sortid && !special && trim(message) == "") {
  2.                 showError('抱歉,您尚未輸入標題或內容');
  3.                 return false;
  4.         } else if(mb_strlen(theform.subject.value) > 200) {
  5.                 showError('您的標題超過 200 個字符的限制');
  6.                 return false;
  7.         }
復制代碼

2、找到文件sitatic/js/forum.js的212到218行代碼:
  1. if(theform.message.value == '' || theform.subject.value == '') {
  2.                 s = '抱歉,您尚未輸入標題或內容';
  3.                 theform.message.focus();
  4.         } else if(mb_strlen(theform.subject.value) > 80) {
  5.                 s = '您的標題超過 80 個字符的限制';
  6.                 theform.subject.focus();
  7.         }
復制代碼
修改為:
  1. if(theform.message.value == '' || theform.subject.value == '') {
  2.                 s = '抱歉,您尚未輸入標題或內容';
  3.                 theform.message.focus();
  4.         } else if(mb_strlen(theform.subject.value) > 80) {
  5.                 s = '您的標題超過 80 個字符的限制';
  6.                 theform.subject.focus();
  7.         }
復制代碼

三、修改模板中寫死的字符限制數:
1、找到文件\template\default\forum\post_editor_extra.htm的25到33行:
  1. <!--{if $_GET[action] != 'reply'}-->
  2.                                 <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>
  3.                         <!--{else}-->
  4.                                 <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>
  5.                                 <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>
  6.                         <!--{/if}-->
  7.                         <span id="subjectchk"{if $_GET[action] == 'reply'} style="display:none"{/if}>{lang comment_message1} <strong id="checklen">80</strong> {lang comment_message2}</span>
  8.                         <script type="text/javascript">strLenCalc($('subject'), 'checklen', 80)</script>
  9.                 <!--{/if}-->
復制代碼
修改為:
  1. <!--{if $_GET[action] != 'reply'}-->
  2.                                 <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', 200);" style="width: 25em" tabindex="1" /></span>
  3.                         <!--{else}-->
  4.                                 <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', 200);return false;">{lang modify}</a>]</span>
  5.                                 <span id="subjectbox" style="display:none"><input type="text" name="subject" id="subject" class="px" value="" onkeyup="strLenCalc(this, 'checklen', 200);" style="width: 25em" /></span>
  6.                         <!--{/if}-->
  7.                         <span id="subjectchk"{if $_GET[action] == 'reply'} style="display:none"{/if}>{lang comment_message1} <strong id="checklen">200</strong> {lang comment_message2}</span>
  8.                         <script type="text/javascript">strLenCalc($('subject'), 'checklen', 200)</script>
  9.                 <!--{/if}-->
復制代碼

2、找到文件\template\default\forum\forumdisplay_fastpost.htm31-32行:
  1. <input type="text" id="subject" name="subject" class="px" value="" onkeyup="strLenCalc(this, 'checklen', 80);" tabindex="11" style="width: 25em" />
  2.                                 <span>{lang comment_message1} <strong id="checklen">80</strong> {lang comment_message2}</span>
復制代碼
修改為:
  1. <input type="text" id="subject" name="subject" class="px" value="" onkeyup="strLenCalc(this, 'checklen', 200);" tabindex="11" style="width: 25em" />
  2.                                 <span>{lang comment_message1} <strong id="checklen">200</strong> {lang comment_message2}</span>
復制代碼

四,修改函數驗證提示:
找到文件source/function/function_post.php的361-363行:
  1. if(dstrlen($subject) > 80) {
  2.                 return 'post_subject_toolong';
  3.         }
復制代碼
修改為:
  1. if(dstrlen($subject) > 200) {
  2. return 'post_subject_toolong';
  3. }
復制代碼

五、找到語言包提示文字,打開 source/language/lang_messege.php 并找到998行改為:
  1. 'post_subject_toolong' => '抱歉,您的標題超過 80 個字符修改標題長度',
復制代碼
修改為:
  1. 'post_subject_toolong' => '抱歉,您的標題超過 200 個字符修改標題長度',
復制代碼

教程已全部完成,別忘記到后臺——工具——更新一下緩存。
下面由源碼專家提供修改為做的測試效果:


作者: 耗子    時間: 2019-6-7 11:11
感謝分享 收藏了
作者: xzaxza    時間: 2019-6-9 08:45
收藏了  ,謝謝

作者: janjou    時間: 2019-6-9 11:39
不錯!不錯!
作者: 元歸    時間: 2019-6-9 16:37
謝謝分享,學習
作者: onetheme    時間: 2019-6-13 20:08
感謝分享!
作者: 白帆    時間: 2019-6-14 19:02
學到了,收藏,謝謝
作者: 站長    時間: 2019-6-16 14:32
感謝 學習一下
作者: 泰然自若    時間: 2019-7-4 11:13
這個修改和DZ3.2的分享帖子是一樣的吧?
http://www.discuz.net/forum.php?mod=viewthread&tid=3594800

我這邊又按照樓主的修改后,為毛要提示超過150字符??大家有這個情況嘛?不知道這個150哪里來的?語言包都沒有這個150?


(, 下載次數: 105)

作者: ygtxzgs    時間: 2019-7-5 00:50
感謝分享 收藏了
作者: 高山少主    時間: 2019-7-5 09:45
先收藏了,謝謝!
作者: 就今天高興    時間: 2019-7-10 01:31
感謝分享 收藏了

作者: 分享之家    時間: 2019-7-27 18:58
肯本無法使用,樓主有測試么
作者: 依依    時間: 2019-9-16 13:15
第三方模板將略過默認模板的修改嘛?
作者: lmusic    時間: 2019-11-20 16:05
謝謝分享,學習
作者: cccbu    時間: 2020-1-15 12:12
我有解除發帖限制80字符的懶人包!上傳就可以了!我qq452999083
作者: xuqiao    時間: 2020-2-28 10:07
非常感謝!
作者: yeah    時間: 2020-7-3 16:22
感謝分享 收藏了
作者: 小小一粒沙    時間: 2021-7-29 10:56
感謝分享 收藏了




歡迎光臨 Discuz! 官方交流社區 (http://www.9999xn.com/) Powered by Discuz! W1.0