Home  >  Article  >  CMS Tutorial  >  Let’s talk about how Discuz changes the character length limit of post titles.

Let’s talk about how Discuz changes the character length limit of post titles.

青灯夜游
青灯夜游forward
2021-01-19 19:08:073719browse

This article will introduce to you DiscuzHow to modify the character length limit of the post title. It has certain reference value. Friends in need can refer to it. I hope it will be helpful to everyone.

Let’s talk about how Discuz changes the character length limit of post titles.

Related recommendations: "discuz Tutorial"

1. Environment

Discuz 3.4

2. Change method

This article limits the character length of the post title to a maximum of 180 characters.

Before executing the sql statement, it is best to back up the database first:

# mysqldump -u root -p Discuz > Discuz.sql

(Discuz represents the database name used by Discuz, and Discuz.sql is the backed up file)

Log in to mysql:

# mysql -u root -p

(If the root account of mysql does not have a password set, just press Enter when prompted to enter the password.)

Switch to the database used by Discuz:

MariaDB [(none)]> use Discuz;

Execute the following three sql statements and modify them to the 180-character limit:

MariaDB [Discuz]> ALTER TABLE `pre_forum_post` CHANGE `subject` `subject` VARCHAR(180) NOT NULL;
MariaDB [Discuz]> ALTER TABLE `pre_forum_rsscache` CHANGE `subject` `subject` char(180) NOT NULL;
MariaDB [Discuz]> ALTER TABLE `pre_forum_thread` CHANGE `subject` `subject` char(180) NOT NULL;

Note: MariaDB [Discuz]> is the prompt. Do not enter it when entering the sql statement.

Modify the number of JS verification characters, back up the file first:

# cp 网站目录/static/js/forum_post.js 网站目录/static/js/forum_post.js_bak

Change the content of forum_post.js file

# vi 网站目录/static/js/forum_post.js

Find the following characters

else if(mb_strlen(theform.subject.value) > 180) {
                showError('您的标题超过 180 个字符的限制');
                return false;

Change 80 into 180 (characters marked in red). Save the file and exit.

Modify the number of JS verification characters, backup file:

# cp 网站目录/static/js/forum.js 网站目录/static/js/forum.js_bak

Edit forum.js file:

# vi 网站目录/static/js/forum.js

Find the following content:

 theform.message.focus();
} else if(mb_strlen(theform.subject.value) > 180) {
        s = '您的标题超过 180 个字符的限制';
        theform.subject.focus();

Change 80 into 180 (characters marked in red). Save the file and exit.

Modify the number of characters in the template, back up the file first:

# cp 网站目录/template/default/forum/post_editor_extra.htm 网站目录/template/default/forum/post_editor_extra.htm_bak

Edit the post_editor_extra.htm file:

# vi 网站目录/template/default/forum/post_editor_extra.htm

Replace all 80s with 180, save the file, and exit.

Modify the character limit in the template, backup file:

# cp 网站目录/template/default/forum/forumdisplay_fastpost.htm 网站目录/template/default/forum/forumdisplay_fastpost.htm_bak

Edit forumdisplay_fastpost.htm file:

# vi 网站目录/template/default/forum/forumdisplay_fastpost.htm

Replace all 80s with 180, save the file, and exit.

Modify function verification prompt, backup file:

# cp 网站目录/source/function/function_post.php 网站目录/source/function/function_post.php_bak

Edit function_post.php file:

# vi 网站目录/source/function/function_post.php

Find the following characters:

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

Change 80 to 180 (characters marked in red). Save the file and exit.

Find the language pack prompt text, backup file:

# cp 网站目录/source/language/lang_message.php 网站目录/source/language/lang_message.php_bak

Edit the lang_message.php file:

# vi 网站目录/source/language/lang_message.php

Find the following content:

'post_subject_toolong' => '抱歉,您的标题超过 180 个字符修改标题长度',
把80改成180(标红色的字符)。保存文件,退出。

Open the Discuz homepage , log in as administrator (admin). Click the Management Center in the upper right corner of the page:

Let’s talk about how Discuz changes the character length limit of post titles.

Enter the administrator's account and password, enter the Management Center, and click Tools-Update Cache-OK. As shown in the figure below:

Let’s talk about how Discuz changes the character length limit of post titles.

# Then restart the browser and it will take effect.

For more programming-related knowledge, please visit: Introduction to Programming! !

The above is the detailed content of Let’s talk about how Discuz changes the character length limit of post titles.. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:csdn.net. If there is any infringement, please contact admin@php.cn delete