香蕉成人伊视频在线观看|学生小视频国产区|yy女主播啪啪啪视频|麻豆传播媒体APP大全免费版官网|瑜伽牲交AV|国产欧美日韩在线天堂区|白浆精品国产91

12下一頁
返回列表 發帖
查看: 24475|回復: 18

Discuz! X3.4論壇標題字數突破80的限制解決方法

83

主題

-6

回帖

3

粉絲

爐火純青

貢獻
2 點
金幣
241 個
樓主
發表于 2019-6-5 15:15:01 |浙江| 只看樓主 |倒序瀏覽 |閱讀模式


在玩論壇的站長朋友,每次發文章標題都受字數的限制,一直找不到解決的辦法,此教程為云墨親自測試的經驗總結,今天就分享給大家。
下面由源碼專家技術分享解決標題限制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 個字符修改標題長度',
復制代碼

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

                               
登錄/注冊后可看大圖


                               
登錄/注冊后可看大圖

評分

參與人數 2貢獻 +1 金幣 +13 收起 理由
yeah + 3 贊一個!
dashen + 1 + 10 很給力!

查看全部評分

回復

使用道具 舉報

15

主題

1930

回帖

3

粉絲

應用開發者

discuz 老兵

貢獻
12 點
金幣
198 個
QQ
沙發
發表于 2019-6-7 11:11:49 |黑龍江| 只看Ta
感謝分享 收藏了
回復

使用道具 舉報

3

主題

123

回帖

3

粉絲

應用開發者

貢獻
0 點
金幣
58 個
板凳
發表于 2019-6-9 08:45:10 |四川| 只看Ta
收藏了  ,謝謝
回復

使用道具 舉報

3

主題

28

回帖

2

粉絲

漸入佳境

貢獻
0 點
金幣
30 個
地板
發表于 2019-6-9 11:39:12 |浙江| 只看Ta
不錯!不錯!
回復

使用道具 舉報

16

主題

173

回帖

2

粉絲

爐火純青

貢獻
17 點
金幣
99 個
5#
發表于 2019-6-9 16:37:21 |浙江| 只看Ta
謝謝分享,學習
回復

使用道具 舉報

21

主題

494

回帖

3

粉絲

應用開發者

貢獻
29 點
金幣
193 個
QQ
6#
發表于 2019-6-13 20:08:12 |江蘇| 只看Ta
感謝分享!
回復

使用道具 舉報

0

主題

2

回帖

0

粉絲

初學乍練

貢獻
0 點
金幣
4 個
7#
發表于 2019-6-14 19:02:18 |河北| 只看Ta
學到了,收藏,謝謝
回復

使用道具 舉報

1

主題

192

回帖

2

粉絲

爐火純青

貢獻
0 點
金幣
32 個
8#
發表于 2019-6-16 14:32:36 |浙江| 只看Ta
感謝 學習一下
回復

使用道具 舉報

6

主題

18

回帖

2

粉絲

漸入佳境

貢獻
0 點
金幣
36 個
9#
發表于 2019-7-4 11:13:09 |四川| 只看Ta
這個修改和DZ3.2的分享帖子是一樣的吧?
http://www.discuz.net/forum.php?mod=viewthread&tid=3594800

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



回復

使用道具 舉報

0

主題

5

回帖

2

粉絲

初學乍練

貢獻
0 點
金幣
5 個
10#
發表于 2019-7-5 00:50:36 |河北| 只看Ta
感謝分享 收藏了
回復

使用道具 舉報

您需要登錄后才可以回帖 登錄 | 立即注冊

本版積分規則

  • 關注公眾號
  • 有償服務微信
  • 有償服務QQ

手機版|小黑屋|Discuz! 官方交流社區 ( 皖ICP備16010102號 |皖公網安備34010302002376號 )|網站地圖|star

GMT+8, 2026-5-31 04:41 , Processed in 0.063498 second(s), 24 queries , Redis On.

Powered by Discuz! X5.0 Licensed

© 2001-2026 Discuz! Team.

關燈 在本版發帖
有償服務QQ
有償服務微信
返回頂部
快速回復 返回頂部 返回列表