Soda Tasting, an online show for those who love soda

Bookmark and Share

Increase Possible Subject Length

Increase Possible Subject Length

Postby Thoul » April 22nd 2004, 1:23 pm

By default, phpBB limits the length of post and topic subjects to 60 characters. On some forums, it is desirable to allow longer subjects, so this is a guide to hacking your phpBB to increase the limit. We will use 120 as the new subject length here, but you can use a different number by simply changing 120 to that number in the instructions that follow.

Before beginning, let me point out some limitations of this guide and the methods we will be using. The maximum subject length allowed by the MySQL database software is 255 characters, and this cannot be exceeded by the methods we will be using (I'll show you how to have longer subjects later). Other database management software (DBMS) may have different character limits. We will also be using SQL queries to alter the database tables. These queries are written for use in MySQL. If you are using another DBMS, you may need to edit the queries before you can use them. Now, on to the hacking!

There are two steps to increasing the subject length. First you need to run a couple of SQL queries, and you can do this using a database utility like phpMyAdmin or a db_update.php file. If you use phpMyAdmin, you may need to change the phpbb_ prefix of the database table names in these queries. The db_update.php file will handle that automatically.
Code: Select all
ALTER TABLE phpbb_posts_text CHANGE post_subject post_subject VARCHAR(120) DEFAULT NULL;
ALTER TABLE phpbb_topics CHANGE topic_title topic_title VARCHAR(120) NOT NULL;


The second step is to edit the posting_body.tpl file of each template installed on your forum. You need to find a certain line in this file, but as you may know, different templates tend to use very different coding. Below, you can see what the line looks like in subSilver.
Code: Select all
<input type="text" name="subject" size="45" maxlength="60" style="width:450px" tabindex="2" class="post" value="{SUBJECT}" />


If you cannot find this exact line, try looking for a line containing name="subject", name=subject, or name='subject'. All of these would be valid, but you'll probably only see the first version in use. Now, check that line to see if in contains the text maxlength="60" (or a variation of it with single or no quotation marks). If you find the line does not contain the maxlength attribute, you can either skip this step for the template you are editing or add the attribute. Now, assuming that the maxlength attribute is there, change the 60 to 120. Here is the subSilver line with this change.
Code: Select all
<input type="text" name="subject" size="45" maxlength="120" style="width:450px" tabindex="2" class="post" value="{SUBJECT}" />


Now your posters can enter subject lines of greater length when making, editing, or replying to posts and private messages.

(As an aside, those familiar with how posting_body.tpl may wonder why we didn't also alter the private message database tables. It isn't necessary, as they already allow subject lengths of up to 255 characters. The 60 character limit is imposed on private messages only by posting_body.tpl.)
User avatar
Thoul
Admin/Webmaster
 
Posts: 18551
Joined: July 30th 2002, 11:30 am
Location: USA

Postby Thoul » April 22nd 2004, 1:39 pm

I mentioned before that there is a 255 character limit when changing the allowed subject length with the method described above. There is one way to exceed this length, but you must be careful when using it. This alternate method allows subjects that can potentially be much longer (as long as the body of an actual post).

To use this method, you need to run a different set of SQL queries (if you've already run those above, that's fine). A third query is included here for private message subjects. If you want to keep those at the default limit (see the note at the end of the above post), skip that query. MySQL users can replace TEXT with TINYTEXT in these queries for shorter (but still very long) subject allowances.
Code: Select all
ALTER TABLE phpbb_posts_text CHANGE post_subject post_subject TEXT DEFAULT NULL;
ALTER TABLE phpbb_topics CHANGE topic_title topic_title TEXT NOT NULL;
ALTER TABLE phpbb_privmsgs CHANGE privmsgs_subject privmsgs_subject TEXT NOT NULL;


The second step is essentially identical to that of the first method. You need to find and change the maxlength attribute to a larger number as described there. The number you use will be the maximum limit of subjects allowed from the posting form. If there is not a maxlength attribute, I strongly suggest adding one, as there will be little other limitations on the subject length. The DBMS will have its own set limit, but that is a very high limit.
User avatar
Thoul
Admin/Webmaster
 
Posts: 18551
Joined: July 30th 2002, 11:30 am
Location: USA


Return to phpBB 2: Customizing Your phpBB

Who is online

Users browsing this forum: No registered users and 0 guests