Renaming custom BBCodes in phpBB 3.2

Get help developing custom BBCodes or request one.
Post Reply
User avatar
Registered User
Posts: 41
Joined: Mon Apr 13, 2015 10:21 am
Location: Czech Republic

Renaming custom BBCodes in phpBB 3.2

Post by Electrix »


recently I have run into some BBCode issues with my board, so I decided I'll try to simplify them as much as possible to avoid future conflits. Let me give you one very simple example:


Code: Select all

[center]centered text[/center]
[left]text on left side[/left]
[right]text on right side[/right]

Code: Select all

[align=center]centered text[/align]
[align=left]text on left side[/align]
[align=right]text on right side[/align]
I already know, how to safely make this BBCode (through special keyword CHOICE). The problem is I need to replace tag name in all existing posts on my board (about 1,5 milion). Sometimes not only BBCode, but also its HTML replacement will slightly change. As far as I know, phpBB doesn't provide any renaming mechanism for that. There is a phpbbcli.php interface for reparsing BBCodes, but I think this is not a situation, where I can use it (or is it?).

I've quickly looked up the "posts" table in MySQL. It seems, that simple saved post with [center] tag (field post_text) looks like this:

Code: Select all

<r><CENTER><s>[center]</s>Example centered text<e>[/center]</e></CENTER></r>
Correct me if I'm wrong assuming both BBCode and its HTML replacement are saved in post side by side. That'd mean the best option will be some PHP script, that will search and replace both BBCode and HTML using regular expressions. But what about fields post_checksum, bbcode_bitfield and bbcode_uid - do they also need to be altered in the process? And more importantly, is there for example some syntatic feature I need to be careful about (in more advanced BBCodes)? Is it possible to somehow reuse the phpbb/textreparser classes for this purpose (and avoid reinventing the wheel)?

I already tried searching on this board and found some similar questions. But all of them were quite old and from what i saw the syntax has changed a lot since then.

So, my question is: Where do I start? I'm sure somebody out there faced similar problem in the past. I'll appreciate any help or advice.
„Only a life lived for others is a life worthwhile.“[A. Einstein]
User avatar
Support Team Member
Support Team Member
Posts: 51597
Joined: Thu Nov 02, 2006 12:21 am
Location: The U.P.
Name: Steve

Re: Renaming custom BBCodes in phpBB 3.2

Post by stevemaury »

How about using SQL to replace all instances of [center] with [align=center], etc., and then using CLI to reparse?


Code: Select all

update phpbb_posts set post_text = replace(post_text, '[center]', '[align=center]')
And so on for the other tags.

I would try this on a test database (copy) first.
For REALLY good and VERY inexpensive hosting CLICK HERE

I can stop all your spam. I can upgrade or update your Board. PM or email me. (Paid support)
Post Reply

Return to “Custom BBCode Development and Requests”