第 1 位会员
日志
粉丝
关注
好友:5922
访客:33479
日志归档
    相册
    目录

    解除Discuz论坛标题字数限制在80个字符的方法

    Discuz / 21/3/16 21:44 / 483 / 1

    今天学习下解除Discuz论坛标题字数限制在80字符的方法
    1.修改JS验证字符数: 找到文件static/js/forum_post.js

    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)

    2、找到文件sitatic/js/forum.js

    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)

    3.修改模板中写死的字符限制数,找到文件template/default/forum/post_editor_extra.htm

    <!--{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="https://www.memacx.com/javascript:;" target="_blank">{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}-->

    把里面的四个数字80改成你想要的数字(比如我改成180)

    4.找到文件template/default/forum/forumdisplay_fastpost.htm

    <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>

    把里面的两个80改成你想要的数字(我改的180)

    5.修改函数验证提示,找到文件source/function/function_post.php

    if(dstrlen($subject) > 80) {
                   return 'post_subject_toolong';
           }

    把80改成你想要的数字(我改的180)

    6.找到语言包提示文字,打开 source/language/lang_messege.php

    'post_subject_toolong' => '抱歉,您的标题超过 80 个字符修改标题长度',

    把80改成180。

    7.数据库修改,修改数据库标题字段的长度为180字符
    找到数据库三个表,pre_forum_post、pre_forum_rsscache、pre_forum_thread,一个个打开点击结构,找到表主题subject(80)点击修改
    改成180保存。三个表都要修改。
    修改完成后,到论坛后台——工具——更新一下缓存即可。

    1
    评论 (1)
    admin
    21/3/16 22:01
    如果是第三方模版请根据自己的模版路径修改相对应的forumdisplay_fastpost.htm,forumpost_editor_extra.htm
    请勿发布不友善或者负能量的內容。与人为善,比聪明更重要!
    您需要登录后才可以评论 登录 | 注册