MyBB Community Forums

Full Version: Gain cross-site bbcode compatibility
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
As I prepare to transfer my community from phpbb to MyBB, this remains toward the top of the to-do list for me. Basically, I'm trying to achieve cross-site compatibility with font-sizes in posts. Due to the nature of my site, people often copy/paste things from their individual sites and thus, sometimes use slightly different size codes (hence the need for this for my site). I used this modification with my phpbb board and I'm hoping it can also be used for MyBB. I'd imagine that it would work the same way since it's just basic php, but I'm unsure exactly what file I'd do the edits in.

Basically, that modification would convert all the size codes (such as "xxsmall," "size=1," or "size=50") to percentages so that they all come out looking the same. It's an amazing modification and I hope it gets put into the basic MyBB structure in a future release. But until then, would anyone happen to know how to achieve this in MyBB? More specifically, does anyone know what file would need edited and where? In phpbb, it was the posting.php file. But I know MyBB structuring is a bit different. Thanks in advance!
/inc/class_parser.php is the file you want.
Thanks! I put the code into that file but it was a disaster haha. I'm guessing it either needs to go in a very specific spot or the base code needs modified to be compatible with MyBB. Just putting it in as is results in an error message of "Parse error: syntax error, unexpected T_VARIABLE, expecting T_FUNCTION"

Here's the actual code from phpbb. Are there any modifications that need made to it to have it work?


// Automatic replacing quotation marks and big letters in BBcode
	$message_parser->message		=  str_replace(array('[SIZE', '[URL', '[COLOR'), array('[size', '[url', '[color'), $message_parser->message);
	$message_parser->message		=  preg_replace(array('/\[size\="(.*?)"\]/is', '/\[url\="(.*?)"\]/is', '/\[color\="(.*?)"\]/is'), array('[size=$1]', '[url=$1]', '[color=$1]'), $message_parser->message);

// Automatic replacing the font size of value to percent
	$message_parser->message		=  str_replace(array('[size=1]', '[size=2]', '[size=3]', '[size=4]', '[size=5]', '[size=6]', '[size=7]'), array('[size=50]', '[size=85]', '[size=100]', '[size=150]', '[size=200]', '[size=300]', '[size=300]'), $message_parser->message);

// Automatic replacing the font size of pixel to percent
	$message_parser->message		=  str_replace(array('[size=12]', '[size=13]', '[size=14]', '[size=15]', '[size=16]', '[size=17]', '[size=18]', '[size=19]', '[size=20]', '[size=21]', '[size=22]', '[size=23]', '[size=24]'), array('[size=80]', '[size=90]', '[size=100]', '[size=110]', '[size=120]', '[size=130]', '[size=140]', '[size=150]', '[size=160]', '[size=170]', '[size=180]', '[size=190]', '[size=200]'), $message_parser->message);
Ewww.

First of all it doesn't work that way, as that code translates bbcodes to phpBB's flavour of bbcodes. You'd have to adapt for MyBB. This adaption could either be done through MyCodes or using a plugin. Code change is the least desireable option, as you'd have to redo them with every MyBB update (or maybe do them using my Patches plugin). Still don't do code changes if you can do it any other way.