马上注册,自学更多教程,下载更多资源。
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
Discuz在标题上有字数限制,但有些时候标题字数确实难以完美的控制在一定范围内,所以不得不将字数扩充一定范围。现在我来给大家分享一下如何修改标题字数限制!
第一步
首先修改数据库,经过我的经验,修改为180字符最为合适,当然,你可以参照你自己的实用需求,运行下面的sql语句:
- ALTER TABLE `pre_forum_post` CHANGE `subject` `subject` VARCHAR(180) NOT NULL;
- ALTER TABLE `pre_forum_rsscache` CHANGE `subject` `subject` char(180) NOT NULL;
- ALTER TABLE `pre_forum_thread` CHANGE `subject` `subject` char(180) NOT NULL;
复制代码由于Discuz! 后台默认情况下禁止 SQL 语句直接执行,只能使用常用 SQL 当中的内容。
如果您想自己随意书写 SQL 升级语句,需要将 config/config_global.php 当中的 $_config[admincp][runquery] 设置修改为 1。
(因为我们这里需要执行SQL语句所以需要改,或者直接在PHPmyadmin 里面执行SQL语句即可)
这里我是修改了config_global.php文件。
第二步
接着修改JS验证字符数:
修改文件static/js/forum_post.js中的(可以Ctrl+F搜索字段)
if(($('postsubmit').name != 'replysubmit' && !($('postsubmit').name == 'editsubmit' && !isfirstpost) && theform.subject.value == "") || !sortid && !special && trim(message) == "") {
showError('抱歉,您尚未输入标题或内容');
return false;
} else if(mb_strlen(theform.subject.value) > 80) {
showError('您的标题超过 80 个字符的限制');
return false;
}
将里边的80字符改为180字符
第三步
修改文件sitatic/js/forum.js中的(可以Ctrl+F搜索字段)
if(theform.message.value == '' && theform.subject.value == '') {
s = '抱歉,您尚未输入标题或内容';
theform.message.focus();
} else if(mb_strlen(theform.subject.value) > 80) {
s = '您的标题超过 80 个字符的限制';
theform.subject.focus();
}
将里边的80字符改为180字符
第四步
修改模板中写死的字符限制数: 找到文件\template\default\forum\post_editor_extra.htm中的(可以Ctrl+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>
将里边的80字符改为180字符
第五步
修改文件\template\default\forum\forumdisplay_fastpost.htm中的(可以Ctrl+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>
将里边的80字符改为180字符
第六步
修改函数验证提示: 修改文件source/function/function_post.php中的(可以Ctrl+F搜索字段)
if(dstrlen($subject) > 80) {
return 'post_subject_toolong';
}
将里边的80字符改为180字符
第七步
找到语言包提示文字
修改source/language/lang_messege.php中的(可以Ctrl+F搜索字段)
'post_subject_toolong' => '抱歉,您的标题超过 80 个字符修改标题长度',
将里边的80字符改为180字符
上一篇:discuz网盘资源下载中心 V4.2.0 x3.2破解插件下载 价值288元 下一篇:discuz!清新地方门户网站模板 |