Post Reply 
 
Thread Rating:
  • 1 Votes - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Converting phpBB BBCodes to MyBB MyCodes
Author Message
Mikers Offline
Tutorials Team Member
***

Posts: 141
Joined: Mar 2010
Reputation: 6
Post: #1
Converting phpBB BBCodes to MyBB MyCodes
phpBB3 BBCodes to MyBB MyCodes Tutorial
by Mikers

Don't be intimidated by the length of this tutorial. I just have a habit of over-explaining things. The process is actually very simple, I just wanted to make sure I explained it so that even those with little coding skills could understand.

While phpBB Codes and MyCodes work a little differently, they're very much alike. And many webmaster should easily be able to convert a BBCode to a MyCode. But just in case, this tutorial should help you when converting your favorite BBCodes to MyCodes for your MyBB Forum.

Relax for any anyone out there who fears a heap of HTML coding requirements or anything difficult. The process is very simple, and has little to do with HTML. And I think the best way to show you is through an example.

So for our example. I'll be converting the Spoiler 3 BBCode created by Sjoerd, over at phpBB3 BBCodes.


To start. Let's take a look at the standard Replacement Codes for this BBCode.


BBCode:
Code:
[spoiler={TEXT2}]{TEXT1}[/spoiler]

HTML Replacement:
Code:
<dl class="codebox"><dt>{TEXT2} | <a href="javascript: void(0);" onclick="var spoiler = this.parentNode.parentNode.getElementsByTagName('dd')[0]; if ( spoiler.style.display == 'none' ) { spoiler.style.display = 'block'; this.innerHTML = '-'; } else { spoiler.style.display = 'none'; this.innerHTML = '+'; };">+</a></dt><dd style="display: none;">{TEXT1}</dd></dl>


Step 1: Replacing the BBCode/MyCode Area

First, I'll show you how to what to replace for the BBCode/MyCode standard Area. For converting any BBCode the process simply stated, goes like this.

Standard BBCode:
Code:
[BBCode]{TEXT1}[/BBCode]

Converted To MyCode:
Code:
\[BBCode\](.*?)\[/BBCode\]

Now, all I really did to convert this area, was add 4 backslashes and replace {TEXT1} with (.*?) , which is standard for MyCode replacements. This conversion is usually global.

A Closer look at the changes,
\[BBCode\](.*?)\[/BBCode\]

The backslashes ALMOST ALWAYS go to those same positions, and always at the end of whatever code you place before those slashes.

Now for a code like the Spoiler 3 BBCode, this may seem harder to convert, but it's really not.

phpBB3 BBCode:
Code:
[spoiler={TEXT2}]{TEXT1}[/spoiler]

To MyCode Conversion:
Code:
\[spoiler=(.*?)\](.*?)\[/spoiler\]

As you can see, it's quite simple even for the BBCodes that have the additions of "[BBCode={TEXT1}]" crap.



Step 2: Replacing the HTML Area

Now on to the HTML Replacement. This really isn't harder, but it is something you still have to pay attention to. So I'll start by bringing in the standard HTML Replacement for the Spoiler 3 BBCode.

Spoiler 3 BBCode HTML Replacement:
Code:
<dl class="codebox"><dt>{TEXT2} | <a href="javascript: void(0);" onclick="var spoiler = this.parentNode.parentNode.getElementsByTagName('dd')[0]; if ( spoiler.style.display == 'none' ) { spoiler.style.display = 'block'; this.innerHTML = '-'; } else { spoiler.style.display = 'none'; this.innerHTML = '+'; };">+</a></dt><dd style="display: none;">{TEXT1}</dd></dl>

Search within that code area, and you'll find two codes to notice. {TEXT2} and {TEXT1}. This sound a bit familiar?

Let me refresh your memory.

phpBB3 BBCode:
Code:
[spoiler={TEXT2}]{TEXT1}[/spoiler]

Yes, the {TEXT2} and {TEXT1} are related in both the HTML Replacement and the BBCode area. This should be common knowledge, but it's important to note this to convert a BBCode to a MyCode.

Now. As you remember from the BBCode area to MyCode area conversion. We replaced both {TEXT1} and {TEXT2} with two (.*?)'s. So now how do we replace the {TEXT1} and {TEXT2} in the HTML replacement?

I'll show you the immediate conversion, and then explain.

phpBB3 BBCode:
Code:
<dl class="codebox"><dt>{TEXT2} | <a href="javascript: void(0);" onclick="var spoiler = this.parentNode.parentNode.getElementsByTagName('dd')[0]; if ( spoiler.style.display == 'none' ) { spoiler.style.display = 'block'; this.innerHTML = '-'; } else { spoiler.style.display = 'none'; this.innerHTML = '+'; };">+</a></dt><dd style="display: none;">{TEXT1}</dd></dl>

To MyCode Conversion:
Code:
<dl class="codebox"><dt>$1 | <a href="javascript: void(0);" onclick="var spoiler = this.parentNode.parentNode.getElementsByTagName('dd')[0]; if ( spoiler.style.display == 'none' ) { spoiler.style.display = 'block'; this.innerHTML = '-'; } else { spoiler.style.display = 'none'; this.innerHTML = '+'; };">+</a></dt><dd style="display: none;">$2</dd></dl>

Do you see what I did there? {TEXT1} was replaced with $2, and {TEXT2} was replaced with $1. But why is that? Well let me show you.

Zooming Back to the MyCode Area Replacement:
Code:
\[spoiler=(.*?)\](.*?)\[/spoiler\]

As you remember, instead of {TEXT1} and {TEXT2} and {TEXT3}, all of these are replaced with (.*?). In the HTML Replacement {TEXT1} is related to {TEXT1} from the BBCode area. In this, (.*?)'s are related to $#'s. But how do you tell which ones?

The (.*?)'s are related to the $#'s in the order that they appear. So to show one of our last examples in the tutorial.

\[spoiler=(.*?)\] is related to $1.
while
(.*?)\[/spoiler\] is related to $2.

You should have an equal number of $#'s in the HTML replacement to the number of the (.*?)'s in the MyCode area replacements. The first (.*?) that appears in the MyCode area would be $1 when reading left to right. The second (.*?) that appears in the MyCode area would be $2. And the third (.*?) would be $3. And so on, and so forth.

So the final conversion of the phpBB3 BBCode Spoiler 3 would be.
MyCode Area:
Code:
\[spoiler=(.*?)\](.*?)\[/spoiler\]

MyCode HTML Replacement:
Code:
<dl class="codebox"><dt>$1 | <a href="javascript: void(0);" onclick="var spoiler = this.parentNode.parentNode.getElementsByTagName('dd')[0]; if ( spoiler.style.display == 'none' ) { spoiler.style.display = 'block'; this.innerHTML = '-'; } else { spoiler.style.display = 'none'; this.innerHTML = '+'; };">+</a></dt><dd style="display: none;">$2</dd></dl>

This conversion method is not true for all BBCodes (especially Mod BBCodes) to MyCodes, but generally...this is the best conversion method for most.

Thanks for reading. And I hope that I didn't confuse you too much in this tutorial, as that's obviously unintended. If you have any further questions, feel free to post them on this topic.

Hope This Helps.
--
Original Topic: http://pulselifeent.com/forum/thread-256.html
My website's still under construction, and isn't meant to be revealed until late May, but whatever.001_tt2
If you enjoyed the tut, and found it helpful, please do me the courtesy of not posting it without my permission. I'll gladly give it to you if you PM me.


WARNING: Be very very careful when using this to convert certain BBCodes. Those BBCodes that use of certain functions for HTML replacement will leave you open to powerful security vulnerabilities. Only use (.*?) when it does not pose a risk for HTML/XSS Injection. I will explain more on this later. Lastly, I'm not responsible for HTML Injections if you do use this method. However, if you do use this tutorial to convert a BBCode, and it works through my standard method, you should be fine - but again, I make no promises at all, and cannot be held responsible. Tongue
(This post was last modified: 04-11-2010, 05:22 PM by Mikers)
04-02-2010, 02:20 PM
Find all posts by this user Quote this message in a reply
Ansem Offline
Member
***

Posts: 198
Joined: Sep 2009
Reputation: 3
Post: #2
RE: Converting phpBB BBCodes to MyBB MyCodes
Usefull ^^, veryyyyyyyyyy usefull <3<3<3...
Will definitely fool around with this.

Thanks !

[Image: dedeno_fullheader1.png] - My website to learn Japanese and about Anime&Manga
Quote:So many are still waiting for their new beginning, their birth by sleep. Even me and even you,
04-02-2010, 05:03 PM
Find all posts by this user Quote this message in a reply
Mikers Offline
Tutorials Team Member
***

Posts: 141
Joined: Mar 2010
Reputation: 6
Post: #3
RE: Converting phpBB BBCodes to MyBB MyCodes
No problem, gent. Wink
04-03-2010, 04:21 AM
Find all posts by this user Quote this message in a reply
Don+ Offline
Member
***

Posts: 68
Joined: Aug 2010
Reputation: 0
Post: #4
RE: Converting phpBB BBCodes to MyBB MyCodes
Great guide,
08-21-2010, 10:41 AM
Find all posts by this user Quote this message in a reply
simonbalol Offline
Junior Member
**

Posts: 10
Joined: Dec 2010
Reputation: 0
Post: #5
RE: Converting phpBB BBCodes to MyBB MyCodes
thank you very much
i hope if u can help me to convert this code
it's good to add alt tag for images
BBCode:
Code:
[imgalt]{URL},{SIMPLETEXT}[/imgalt]

HTML:
Code:
<img src="{URL}" alt="{SIMPLETEXT}" title="{SIMPLETEXT}" />

thank u again
12-12-2010, 04:43 PM
Find all posts by this user Quote this message in a reply
ms365 Offline
MybbSource Skinner
***

Posts: 95
Joined: Dec 2009
Reputation: 1
Post: #6
RE: Converting phpBB BBCodes to MyBB MyCodes
Nice Tut there, xD.


(12-12-2010 04:43 PM)simonbalol Wrote:  thank you very much
i hope if u can help me to convert this code
it's good to add alt tag for images
BBCode:
Code:
[imgalt]{URL},{SIMPLETEXT}[/imgalt]

HTML:
Code:
<img src="{URL}" alt="{SIMPLETEXT}" title="{SIMPLETEXT}" />

thank u again
The BBCode:

Code:
\[imgalt\](.*?),(.*?)\[/imgalt\]

HTML:

Code:
<img src="$1" alt="$2" title="$2" />
(This post was last modified: 12-13-2010, 02:25 AM by ms365)
12-13-2010, 02:21 AM
Find all posts by this user Quote this message in a reply
simonbalol Offline
Junior Member
**

Posts: 10
Joined: Dec 2010
Reputation: 0
Post: #7
RE: Converting phpBB BBCodes to MyBB MyCodes
Smile
thank you very much
it's working well

for all u can check it here
(This post was last modified: 12-13-2010, 04:24 AM by simonbalol)
12-13-2010, 04:06 AM
Find all posts by this user Quote this message in a reply
ms365 Offline
MybbSource Skinner
***

Posts: 95
Joined: Dec 2009
Reputation: 1
Post: #8
RE: Converting phpBB BBCodes to MyBB MyCodes
Haha, Welcome Big Grin.By the way, Dell wallpapers are cool Tongue Wink Using inspiron now Tongue
(This post was last modified: 12-13-2010, 04:51 AM by ms365)
12-13-2010, 04:49 AM
Find all posts by this user Quote this message in a reply
Gabriel Offline
Junior Member
**

Posts: 7
Joined: Dec 2010
Reputation: 0
Post: #9
RE: Converting phpBB BBCodes to MyBB MyCodes
Thanks, that helped me a lot +rep for u 001_smile
12-13-2010, 05:26 AM
Find all posts by this user Quote this message in a reply
manfi Offline
Junior Member
**

Posts: 21
Joined: May 2010
Reputation: 0
Post: #10
RE: Converting phpBB BBCodes to MyBB MyCodes
I think a Generator would be Greater, but thanks mate
12-19-2010, 11:08 PM
Find all posts by this user Quote this message in a reply
Post Reply 




User(s) browsing this thread: 1 Guest(s)