ms365
MybbSource Skinner
  
Posts: 95
Joined: Dec 2009
Reputation: 1
|
Making your own codes!
With MyCodes, you can create your own bbcodes.Some pre-added bbcodes in Mybb are:
-Bold
-Italicize
-Underline
To make your own bbcodes, you should have some knowledge of HTML.
How it works:
Converts the bbcodes(which users enter in their post) into HTML which is executed and shown to the user's browser.
It tells the user's browser that [ b ] means <b> and hence, [ b ] is converted to <b>
How to create my own MyCode?
1)Go on your Forum
2)Log-on to Admin Control Panel
3)Click on the "Configuration" tab
4)Then click on "MyCode"
5)You will see here the lists of MyCode you have made.But now, there will be none! Because you haven't created any!
So click on "Add new MyCode"
6)You will see a page where it will ask for the following things:
Title The name of the code you are gonna make
Short Description A short description about what your code will do
Regular Expression Users will enter this in their posts
Replacement The conversion of "Regular Expression/BBCODE(USER WILL ENTER)" to HTML.
Enabled Can the users use this code?
Parse order The order at which your code will be in the MyCodes list.
7)So we will be creating a code which will allow the users to chose the direction of the text! (I have already added this mycode in the mycodes section)Though, I have made a bit tough codes which I do not want to post here, so we will go with this one.
Title Type "Text Direction"
Short Description Type "Allows user to select the direction of the text"
Regular Expression Ok.So here is the major part of making your code.
This is what users will enter.
In the bold code, this would be entered here:
\[ b \](.*?)\[ /b \]
-Before every square bracket, you must but a "\"(without quotes).
-(.*?) is a variable.Now this means that a user will enter something here.
So the user in his post will enter:
[ b ]Any text [ /b ]
And the result will be this:
Any text
---Text Direction Regular Expression
Now this is the Regular expression for our Text direction code.Type this:
\[direction=(.*?)\](.*?)\[/direction\]
As you can clearly see, I have put a slash before every square bracket.And the first (.*?) (After the "=" ) will allow the user to select the direction of the text.And the second (.*?) (Between the direction tags) will be the text the user will input.
So the code user will enter is( do not enter this code in the Regular Expressions):
[direction=THEDIRECTION]THE TEXT[/direction]
Replacement
The Replacement code is always in HTML.So the Replacement will be this:
<bdo dir=$1>$2</bdo>
The "bdo" tag , in html is used for the same purpose we are making the MyCode for i.e it will allow the user to select the direction in HTML.And "bdo" tag's attribute is "dir" which is where the direction is selected.There can be two values here: rtl(right to left) and ltr(left to right).
Now see "$1" is the replacement of (.*?).$ means that this is a variable.And the number after it is the order of the (.*?).
So $1 is referred as \[direction=(.*?)\](.*?)\[/direction\](The bold text) here.And $2 is referred as \[direction=(.*?)\](.*?)\[/direction\] here.As you add variables in the Regular Expressions, you have to define them in Replacement too.Here, I've defined both the (.*?) as $1 and $2.If you create more (.*?), there will be more Replacement variables like $3, $4 written at its respective place.
Enabled Select Yes.
Parse order Type 1 if you haven't made any other MyCode.
Tada! Your MyCode is ready!
If you have any other questions, just ask me!
(This post was last modified: 04-22-2010, 04:54 AM by ms365)
|
|
| 04-22-2010, 04:54 AM |
|
flipflops
Junior Member
 
Posts: 5
Joined: Dec 2010
Reputation: 0
|
RE: Making your own codes!
It is very easy to write your own Html codes.There are many Html website available .
(This post was last modified: 12-04-2010, 02:42 PM by flipflops)
|
|
| 12-03-2010, 10:29 PM |
|