在玩論壇的站長(zhǎng)朋友,每次發(fā)文章標(biāo)題都受字?jǐn)?shù)的限制,一直找不到解決的辦法,此教程為云墨親自測(cè)試的經(jīng)驗(yàn)總結(jié),今天就分享給大家。
下面由源碼專(zhuān)家技術(shù)分享解決標(biāo)題限制80字符方法步驟:
一、數(shù)據(jù)庫(kù)修改;
二、修改JS驗(yàn)證字符數(shù)文件;
三、修改模板中寫(xiě)死的字符限制數(shù);
四,修改函數(shù)驗(yàn)證文件;
五,修改語(yǔ)言包文件。
一、數(shù)據(jù)庫(kù)修改,修改數(shù)據(jù)庫(kù)標(biāo)題字段的長(zhǎng)度為200字符:運(yùn)行下面的sql語(yǔ)句:
(注意修改你的表的前綴)
- ALTER TABLE `pre_forum_post` CHANGE `subject` `subject` VARCHAR(200) NOT NULL;
- ALTER TABLE `pre_forum_rsscache` CHANGE `subject` `subject` char(200) NOT NULL;
- ALTER TABLE `pre_forum_thread` CHANGE `subject` `subject` char(200) NOT NULL;
復(fù)制代碼
二、修改JS驗(yàn)證字符數(shù):
1、找到文件static/js/forum_post.js的75-81行
- if(($('postsubmit').name != 'replysubmit' && !($('postsubmit').name == 'editsubmit' && !isfirstpost) && theform.subject.value == "") || !sortid && !special && trim(message) == "") {
- showError('抱歉,您尚未輸入標(biāo)題或內(nèi)容');
- return false;
- } else if(mb_strlen(theform.subject.value) > 80) {
- showError('您的標(biāo)題超過(guò) 80 個(gè)字符的限制');
- return false;
- }
復(fù)制代碼修改為:
- if(($('postsubmit').name != 'replysubmit' && !($('postsubmit').name == 'editsubmit' && !isfirstpost) && theform.subject.value == "") || !sortid && !special && trim(message) == "") {
- showError('抱歉,您尚未輸入標(biāo)題或內(nèi)容');
- return false;
- } else if(mb_strlen(theform.subject.value) > 200) {
- showError('您的標(biāo)題超過(guò) 200 個(gè)字符的限制');
- return false;
- }
復(fù)制代碼
2、找到文件sitatic/js/forum.js的212到218行代碼:
- if(theform.message.value == '' || theform.subject.value == '') {
- s = '抱歉,您尚未輸入標(biāo)題或內(nèi)容';
- theform.message.focus();
- } else if(mb_strlen(theform.subject.value) > 80) {
- s = '您的標(biāo)題超過(guò) 80 個(gè)字符的限制';
- theform.subject.focus();
- }
復(fù)制代碼修改為:
- if(theform.message.value == '' || theform.subject.value == '') {
- s = '抱歉,您尚未輸入標(biāo)題或內(nèi)容';
- theform.message.focus();
- } else if(mb_strlen(theform.subject.value) > 80) {
- s = '您的標(biāo)題超過(guò) 80 個(gè)字符的限制';
- theform.subject.focus();
- }
復(fù)制代碼
三、修改模板中寫(xiě)死的字符限制數(shù):
1、找到文件\template\default\forum\post_editor_extra.htm的25到33行:
- <!--{if $_GET[action] != 'reply'}-->
- <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>
- <!--{else}-->
- <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>
- <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>
- <!--{/if}-->
- <span id="subjectchk"{if $_GET[action] == 'reply'} style="display:none"{/if}>{lang comment_message1} <strong id="checklen">80</strong> {lang comment_message2}</span>
- <script type="text/javascript">strLenCalc($('subject'), 'checklen', 80)</script>
- <!--{/if}-->
復(fù)制代碼修改為:
- <!--{if $_GET[action] != 'reply'}-->
- <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>
- <!--{else}-->
- <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>
- <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>
- <!--{/if}-->
- <span id="subjectchk"{if $_GET[action] == 'reply'} style="display:none"{/if}>{lang comment_message1} <strong id="checklen">200</strong> {lang comment_message2}</span>
- <script type="text/javascript">strLenCalc($('subject'), 'checklen', 200)</script>
- <!--{/if}-->
復(fù)制代碼
2、找到文件\template\default\forum\forumdisplay_fastpost.htm31-32行: - <input type="text" id="subject" name="subject" class="px" value="" onkeyup="strLenCalc(this, 'checklen', 80);" tabindex="11" style="width: 25em" />
- <span>{lang comment_message1} <strong id="checklen">80</strong> {lang comment_message2}</span>
復(fù)制代碼修改為:
- <input type="text" id="subject" name="subject" class="px" value="" onkeyup="strLenCalc(this, 'checklen', 200);" tabindex="11" style="width: 25em" />
- <span>{lang comment_message1} <strong id="checklen">200</strong> {lang comment_message2}</span>
復(fù)制代碼
四,修改函數(shù)驗(yàn)證提示:
找到文件source/function/function_post.php的361-363行:
- if(dstrlen($subject) > 80) {
- return 'post_subject_toolong';
- }
復(fù)制代碼修改為:
- if(dstrlen($subject) > 200) {
- return 'post_subject_toolong';
- }
復(fù)制代碼
五、找到語(yǔ)言包提示文字,打開(kāi) source/language/lang_messege.php 并找到998行改為:
- 'post_subject_toolong' => '抱歉,您的標(biāo)題超過(guò) 80 個(gè)字符修改標(biāo)題長(zhǎng)度',
復(fù)制代碼修改為:
- 'post_subject_toolong' => '抱歉,您的標(biāo)題超過(guò) 200 個(gè)字符修改標(biāo)題長(zhǎng)度',
復(fù)制代碼
教程已全部完成,別忘記到后臺(tái)——工具——更新一下緩存。
下面由源碼專(zhuān)家提供修改為做的測(cè)試效果:
![]() |