MyBB Community Forums

Full Version: Hard-Coding BBCodes
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
I want to add a bbcode that requires a PHP script. I figured it out on vBulletin, but is it doable on MyBB?
Can you explain a bit further?

This is code discussion, so I'll move it to the right section of this forum...
Like, I have a certain bbcode called [mana]. It processes the string entered in the tags, and if it matches certain characters it produces a certain image. And I have the PHP code needed for it in base form, I just need to figure out how to connect it to MyBB.
I imagine I could do it with MyCode and regex, but that would be insanely tedious and I'm not sure how to work in an if-statement.
I think you would have to add a custom MyCode.
You need to program a plugin using the parse_message hook.
Something like this may be what you want:

Regular Expression:
\[mana\](char1|something else|blah)\[/mana\]
Replacement:
<img src="images/mana/$1.png" alt="" />

In the above, users can enter "char1", "something else" or "blah" to point to the relevant image. Hope you understand the above.
What does that mean in the code bars?
@tecchie: little more info?
"|" refers to multiple possibilities.
For the above, a user could enter:
[mana]char1[/mana]
or
[mana]something else[/mana]
for example.
Yeah, but the idea is that there are a few dozen possibilities and that mana will pick up a combination of them and spit out that many; like [mana]1ubg[/mana] will enter [Image: 1mana1.gif][Image: 1manau.gif][Image: 1manag.gif][Image: 1manab.gif], while [mana]ggg[/mana] would give off [Image: 1manag.gif][Image: 1manag.gif][Image: 1manag.gif]... I'd give the actual php code, but I'd rather keep it something of a secret (competition, etc). It suffices to say it uses if clauses and the .= command a lot.
Aaaand necro.

Can anyone help me with this? It's an issue again...
Pages: 1 2