設為首頁收藏本站

會員名稱  取回密碼
 註冊
img_loading
智能检测中
搜尋
熱搜: Redump discuz
檢視: 904|回覆: 0

【轉貼】 Discuz! X3.4標題字數突破80的解決方法

[複製連結]
發表於 2021年4月6日 16:05:13 | 顯示全部內容 |閱讀模式
字體大小 16px
10px 32px
修改論壇標題字數限制,下面五個部分需要修改:

一、資料庫
二、JS驗證
三、模板限制
四,函數驗證
五,語言包

現以把標題字符限制80修改為120為例子:

一、資料庫修改資料庫標題字段的長度為120字符:執行下面的sql語句:
(注意修改你的表的前綴)
  1. ALTER TABLE `pre_forum_post` CHANGE `subject` `subject` VARCHAR(120) NOT NULL;
  2. ALTER TABLE `pre_forum_rsscache` CHANGE `subject` `subject` char(120) NOT NULL;
  3. ALTER TABLE `pre_forum_thread` CHANGE `subject` `subject` char(120) NOT NULL;


或是把pre_forum_post、pre_forum_rsscache、pre_forum_thread的subject長度改成120

底下的全部都是需要把80改成120的文件

二、JS驗證:
       1、找到 static/js/forum_post.js
  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.         }



2、找到 sitatic/js/forum.js
  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 有5個 "80" 要修改
  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}-->



      2、找到文件\template\default\forum\forumdisplay_fastpost.htm
  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>



四,修改函數驗證提示:
       找到文件source/function/function_post.php
  1. if(dstrlen($subject) > 80) {
  2.                 return 'post_subject_toolong';
  3.         }



五、找到語言包提示文字,打開 source/language/lang_messege.php
  1. 'post_subject_toolong' => '抱歉,您的標題超過 80 個字元修改標題長度',
作者文章推薦
懶得打字嗎?讓本助手協助你 【使用進階編輯器請點選右方進階模式】
您需要登入後才可以回覆 登入 | 註冊

本版積分規則

手機版|Archiver|漁家小舖

GMT+8, 2025年3月10日 00:14 , Processed in 11.785186 second(s), 13 queries , Gzip On, Redis On.

Powered by Discuz! X3.5

© 2001-2025 Discuz! Team.

快速回覆 返回頂端 返回清單