Discuz! X2.5論壇標(biāo)題字?jǐn)?shù)突破80的限制實(shí)現(xiàn)思路
發(fā)布時(shí)間:2012-12-13 16:44:59 作者:佚名
我要評(píng)論

當(dāng)一些用戶發(fā)布帖子的時(shí)候標(biāo)題要是超過(guò)了80個(gè)字符超出的部分被剪切掉了,特別是一些用戶發(fā)送一些英文或其他其語(yǔ)言的文章的時(shí)候標(biāo)題說(shuō)甚至?xí)^(guò)180個(gè)字符,本文將介紹解決方法,需要了解的朋友可以參考下
當(dāng)一些用戶發(fā)布帖子的時(shí)候標(biāo)題要是超過(guò)了80個(gè)字符超出的部分被剪切掉了,特別是一些用戶發(fā)送一些英文或其他其語(yǔ)言的文章的時(shí)候標(biāo)題說(shuō)甚至?xí)^(guò)180個(gè)字符,又特別論壇編碼是UTF-8格式,因?yàn)橐粋€(gè)字占3個(gè)字節(jié),所以標(biāo)題最長(zhǎng)也就26個(gè)漢字,很多用戶想修改這個(gè)80個(gè)字符的限制。
想去掉這個(gè)字?jǐn)?shù)限制,要從下面五個(gè)部分來(lái)修改:
一、數(shù)據(jù)庫(kù)修改;
二、修改JS驗(yàn)證字符數(shù)文件;
三、修改模板中寫(xiě)死的字符限制數(shù);
四,修改函數(shù)驗(yàn)證文件;
五,修改語(yǔ)言包文件。
現(xiàn)以把標(biāo)題字符限制80修改為120為例子,描述一下修改方法:
一、數(shù)據(jù)庫(kù)修改,修改數(shù)據(jù)庫(kù)標(biāo)題字段的長(zhǎng)度為120字符:運(yùn)行下面的sql語(yǔ)句:
(注意修改你的表的前綴)
ALTER TABLE `pre_forum_post` CHANGE `subject` `subject` VARCHAR(120) NOT NULL;
ALTER TABLE `pre_forum_rsscache` CHANGE `subject` `subject` char(120) NOT NULL;
ALTER TABLE `pre_forum_thread` CHANGE `subject` `subject` char(120) NOT NULL;
二、修改JS驗(yàn)證字符數(shù):1、找到文件static/js/forum_post.js的74-80行
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;
}
修改為:
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) > 120) {
showError('您的標(biāo)題超過(guò) 120 個(gè)字符的限制');
return false;
}
2、找到文件sitatic/js/forum.js的209到215行代碼:
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();
}
修改為:
if(theform.message.value == '' && theform.subject.value == '') {
s = '抱歉,您尚未輸入標(biāo)題或內(nèi)容';
theform.message.focus();
} else if(mb_strlen(theform.subject.value) > 120) {
s = '您的標(biāo)題超過(guò) 120 個(gè)字符的限制';
theform.subject.focus();
}
三、修改模板中寫(xiě)死的字符限制數(shù):
1、找到文件templatedefaultforumpost_editor_extra.htm的25到31行:
<!--{if $_G[gp_action] != 'reply'}-->
<span><input type="text" name="subject" id="subject" class="px" value="$postinfo[subject]" {if $_G[gp_action] == 'newthread'}onblur="if($('tags')){relatekw('-1','-1'{if $_G['group']['allowposttag']},function(){extraCheck(4)}{/if});doane();}"{/if} style="width: 25em" tabindex="1" /></span>
<!--{else}-->
<span id="subjecthide" class="z">RE: $thread[subject] [<a href="javascript:;">{lang modify}</a>]</span>
<span id="subjectbox" style="display:none"><input type="text" name="subject" id="subject" class="px" value="" style="width: 25em" /></span>
<!--{/if}-->
<span id="subjectchk"{if $_G[gp_action] == 'reply'} style="display:none"{/if}>{lang comment_message1} <strong id="checklen">80</strong> {lang comment_message2}</span>
修改為下面代碼:
<!--{if $_G[gp_action] != 'reply'}-->
<span><input type="text" name="subject" id="subject" class="px" value="$postinfo[subject]" {if $_G[gp_action] == 'newthread'}onblur="if($('tags')){relatekw('-1','-1'{if $_G['group']['allowposttag']},function(){extraCheck(4)}{/if});doane();}"{/if} style="width: 25em" tabindex="1" /></span>
<!--{else}-->
<span id="subjecthide" class="z">RE: $thread[subject] [<a href="javascript:;">{lang modify}</a>]</span>
<span id="subjectbox" style="display:none"><input type="text" name="subject" id="subject" class="px" value="" style="width: 25em" /></span>
<!--{/if}-->
<span id="subjectchk"{if $_G[gp_action] == 'reply'} style="display:none"{/if}>{lang comment_message1} <strong id="checklen">120</strong> {lang comment_message2}</span>
2、找到文件templatedefaultforumforumdisplay_fastpost.htm31-32行:
<input type="text" id="subject" name="subject" class="px" value="" tabindex="11" style="width: 25em" />
<span>{lang comment_message1} <strong id="checklen">80</strong> {lang comment_message2}</span>
修改為:
<input type="text" id="subject" name="subject" class="px" value="" tabindex="11" style="width: 25em" />
<span>{lang comment_message1} <strong id="checklen">120</strong> {lang comment_message2}</span>
四,修改函數(shù)驗(yàn)證提示:
找到文件source/function/function_post.php的346-348行:
if(dstrlen($subject) > 80) {
return 'post_subject_toolong';
}
修改為:
if(dstrlen($subject) > 120) {
return 'post_subject_toolong';
}
五、找到語(yǔ)言包提示文字,打開(kāi) source/language/lang_messege.php 并找到985行改為:
'post_subject_toolong' => '抱歉,您的標(biāo)題超過(guò) 120 個(gè)字符修改標(biāo)題長(zhǎng)度',
OK,你再發(fā)表帖子標(biāo)題就可以是120個(gè)字符數(shù)了!??!
想去掉這個(gè)字?jǐn)?shù)限制,要從下面五個(gè)部分來(lái)修改:
一、數(shù)據(jù)庫(kù)修改;
二、修改JS驗(yàn)證字符數(shù)文件;
三、修改模板中寫(xiě)死的字符限制數(shù);
四,修改函數(shù)驗(yàn)證文件;
五,修改語(yǔ)言包文件。
現(xiàn)以把標(biāo)題字符限制80修改為120為例子,描述一下修改方法:
一、數(shù)據(jù)庫(kù)修改,修改數(shù)據(jù)庫(kù)標(biāo)題字段的長(zhǎng)度為120字符:運(yùn)行下面的sql語(yǔ)句:
(注意修改你的表的前綴)
復(fù)制代碼
代碼如下:ALTER TABLE `pre_forum_post` CHANGE `subject` `subject` VARCHAR(120) NOT NULL;
ALTER TABLE `pre_forum_rsscache` CHANGE `subject` `subject` char(120) NOT NULL;
ALTER TABLE `pre_forum_thread` CHANGE `subject` `subject` char(120) NOT NULL;
二、修改JS驗(yàn)證字符數(shù):1、找到文件static/js/forum_post.js的74-80行
復(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) > 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) > 120) {
showError('您的標(biāo)題超過(guò) 120 個(gè)字符的限制');
return false;
}
2、找到文件sitatic/js/forum.js的209到215行代碼:
復(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ù)制代碼
代碼如下:if(theform.message.value == '' && theform.subject.value == '') {
s = '抱歉,您尚未輸入標(biāo)題或內(nèi)容';
theform.message.focus();
} else if(mb_strlen(theform.subject.value) > 120) {
s = '您的標(biāo)題超過(guò) 120 個(gè)字符的限制';
theform.subject.focus();
}
三、修改模板中寫(xiě)死的字符限制數(shù):
1、找到文件templatedefaultforumpost_editor_extra.htm的25到31行:
復(fù)制代碼
代碼如下:<!--{if $_G[gp_action] != 'reply'}-->
<span><input type="text" name="subject" id="subject" class="px" value="$postinfo[subject]" {if $_G[gp_action] == 'newthread'}onblur="if($('tags')){relatekw('-1','-1'{if $_G['group']['allowposttag']},function(){extraCheck(4)}{/if});doane();}"{/if} style="width: 25em" tabindex="1" /></span>
<!--{else}-->
<span id="subjecthide" class="z">RE: $thread[subject] [<a href="javascript:;">{lang modify}</a>]</span>
<span id="subjectbox" style="display:none"><input type="text" name="subject" id="subject" class="px" value="" style="width: 25em" /></span>
<!--{/if}-->
<span id="subjectchk"{if $_G[gp_action] == 'reply'} style="display:none"{/if}>{lang comment_message1} <strong id="checklen">80</strong> {lang comment_message2}</span>
修改為下面代碼:
復(fù)制代碼
代碼如下:<!--{if $_G[gp_action] != 'reply'}-->
<span><input type="text" name="subject" id="subject" class="px" value="$postinfo[subject]" {if $_G[gp_action] == 'newthread'}onblur="if($('tags')){relatekw('-1','-1'{if $_G['group']['allowposttag']},function(){extraCheck(4)}{/if});doane();}"{/if} style="width: 25em" tabindex="1" /></span>
<!--{else}-->
<span id="subjecthide" class="z">RE: $thread[subject] [<a href="javascript:;">{lang modify}</a>]</span>
<span id="subjectbox" style="display:none"><input type="text" name="subject" id="subject" class="px" value="" style="width: 25em" /></span>
<!--{/if}-->
<span id="subjectchk"{if $_G[gp_action] == 'reply'} style="display:none"{/if}>{lang comment_message1} <strong id="checklen">120</strong> {lang comment_message2}</span>
2、找到文件templatedefaultforumforumdisplay_fastpost.htm31-32行:
復(fù)制代碼
代碼如下:<input type="text" id="subject" name="subject" class="px" value="" 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="" tabindex="11" style="width: 25em" />
<span>{lang comment_message1} <strong id="checklen">120</strong> {lang comment_message2}</span>
四,修改函數(shù)驗(yàn)證提示:
找到文件source/function/function_post.php的346-348行:
復(fù)制代碼
代碼如下:if(dstrlen($subject) > 80) {
return 'post_subject_toolong';
}
修改為:
復(fù)制代碼
代碼如下:if(dstrlen($subject) > 120) {
return 'post_subject_toolong';
}
五、找到語(yǔ)言包提示文字,打開(kāi) source/language/lang_messege.php 并找到985行改為:
復(fù)制代碼
代碼如下:'post_subject_toolong' => '抱歉,您的標(biāo)題超過(guò) 120 個(gè)字符修改標(biāo)題長(zhǎng)度',
OK,你再發(fā)表帖子標(biāo)題就可以是120個(gè)字符數(shù)了!??!
相關(guān)文章
Discuz! X3.4默認(rèn)模板自適應(yīng)手機(jī)與pc的方法
這是我去年自己花了一個(gè)下午一點(diǎn)點(diǎn)研究出來(lái)的,現(xiàn)在免費(fèi)貢獻(xiàn)給大家試用,代碼放入后臺(tái)統(tǒng)計(jì)即可,效果如下2020-11-16- 如果想要404頁(yè)面跟網(wǎng)站其他頁(yè)面一樣帶有頂部和底部導(dǎo)航,能顯示用戶信息怎么辦呢?今天小編就為大家介紹discuz設(shè)置嵌入式404頁(yè)面教程,來(lái)看看吧2016-05-10
Discuz X3/3.1 門戶中的Keyword和Description顯示不正確的解決方法
這篇文章主要介紹了Discuz X3/3.1 門戶中的Keyword和Description顯示不正確的解決方法,默認(rèn)顯示的是游客能看到的,而Discuz 對(duì)游客屏蔽了關(guān)鍵詞與描述,為了SEO,還是讓它正常2015-03-25Discuz提示您安裝的不是正版應(yīng)用問(wèn)題解決辦法
這篇文章主要介紹了Discuz提示您安裝的不是正版應(yīng)用問(wèn)題解決辦法,完整提示“對(duì)不起,您安裝的不是正版應(yīng)用,安裝程序無(wú)法繼續(xù)執(zhí)行”,本文使用修改PHP文件的方法解決了這個(gè)2015-03-25- 這篇文章主要介紹了Discuz和jQuery變量名沖突的3種解決方法,在開(kāi)發(fā)模板或者插件時(shí)經(jīng)常遇到這個(gè)問(wèn)題,本文列出的3種方法都可以解決這個(gè)問(wèn)題,需要的朋友可以參考下2015-03-25
Discuz提示“密碼錯(cuò)誤次數(shù)過(guò)多,請(qǐng)15分鐘后重新登陸”問(wèn)題解決方法
這篇文章主要介紹了Discuz提示“密碼錯(cuò)誤次數(shù)過(guò)多,請(qǐng)15分鐘后重新登陸”問(wèn)題解決方法,本文方法適合網(wǎng)站管理員操作,不是普通網(wǎng)友可以使用的解決方法,需要的朋友可以參考下2015-03-25Discuz X2通過(guò)數(shù)據(jù)庫(kù)批量替換修改帖子內(nèi)容
帖子數(shù)量上萬(wàn),一開(kāi)始是通過(guò)設(shè)置詞語(yǔ)過(guò)濾,發(fā)現(xiàn)無(wú)效果,只能通過(guò)數(shù)據(jù)庫(kù)批量替換了,具體方法請(qǐng)接著往下看2014-09-04Discuz!X3.2版設(shè)置論壇QQ在線客服號(hào)碼無(wú)法發(fā)起聊天的問(wèn)題解決辦法
這篇文章主要介紹了Discuz!X3.2版設(shè)置論壇QQ在線客服號(hào)碼無(wú)法發(fā)起聊天的問(wèn)題解決辦法,需要的朋友可以參考下2014-08-03- 這篇文章主要為大家介紹了Discuz論壇發(fā)帖技巧,需要的朋友可以參考下2014-06-21
- 這篇文章主要為大家介紹了Discuz論壇宣傳與優(yōu)化技巧,需要的朋友可以參考下2014-06-21