Home > CMS Tutorial > Discuz > body text

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

青灯夜游
Release: 2021-02-22 17:57:16
forward
3727 people have browsed it

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
Copy after login

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

Log in to mysql:

# mysql -u root -p
Copy after login

(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;
Copy after login

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;
Copy after login

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
Copy after login

Change the content of forum_post.js file

# vi 网站目录/static/js/forum_post.js
Copy after login

Find the following characters

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

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
Copy after login

Edit forum.js file:

# vi 网站目录/static/js/forum.js
Copy after login

Find the following content:

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

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
Copy after login

Edit the post_editor_extra.htm file:

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

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
Copy after login

Edit forumdisplay_fastpost.htm file:

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

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
Copy after login

Edit function_post.php file:

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

Find the following characters:

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

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
Copy after login

Edit the lang_message.php file:

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

Find the following content:

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

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

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

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

Related labels:
source:csdn.net
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template