
Custom bbCodes allow you to give users special bbCodes to use in their posts. Some bbCodes are already supplied by default, but you may want to create others for special purposes, popular HTML sequences, etc.
A Custom bbCode is basically just a Perl regex. To create a new Custom bbCode, view the Admin Area on your board, then click the Custom bbCodes button. You will see a select box and 4 text boxes:
- Forum the bbCode applies in - Select either ``All Forums'', or a specific forum where you wish the new bbCode to be used in.
- From (First text box) - This is the perl regex. Some examples:
size=(\d+) (allows a user to type [size=2], for example)
picture=(.*?) (allows a user to type [picture=bob.jpg])
marquee (allows a user to type [marquee])
Note that if your Custom bbCode must have a closing tag, you must create that separately:
/size ([/size])
/marquee ([/marquee])
- To (Large text box) - This is the HTML to replace the bbCode with. If you included parenthesis in your From regex, you can include the Perl $1, $2, $3 etc variables where needed. For example, for the [size=(\d+)] bbCode above, you could create the HTML:
<font size="$1">
- Short description of the bbCode - A simple description, such as ``Inserts an area of colored text''.
- Insert javascript - Advanced. If you are creating a normal bbCode (with no parenthesis in the regex), you can leave this blank. However, if you have parenthesis, you need to enter either one or two arguments to a javascript function, including exactly what to insert into the post when the user clicks on the button for your Custom bbCode.
Here's an example. You create a bbCode with the regex: size=(\d+) This regex includes perl parenthesis, so you need to enter the javascript with a default value: '[size=2]','[/size]' (This assumes that you then also create a /size bbCode. You need to enter the single-quotes and the comma too.)
For a bbCode without a closing ([/code]) tag, you can simply enter one argument, like: '[picture=bob.jpg]' This assumes that there is no [/picture] tag. You still need to include the single quotes.
Why do you need to enter this javascript argument? When your Custom bbCode is shown with the others, the user viewing the page can click it to insert it into the post he's making. To aid simplicity for the user, Custom bbCodes should work exactly like normal bbCodes - i.e they insert when you click them. As Custom bbCodes can include almost anything, the software can't guess what to insert if the bbCode contains parenthesis. You therefore need to provide the default value.
The actual code used to display the link is: <a href=``javascript:;'' onClick=``window.opener.Insert($toins);''[$from]</a>> ($toins is the javascript arguments you entered above, $from is the From name of the bbCode).
If you didn't understand any of this, you can safely leave the javascript box blank. It will simply enter the name of the bbCode, without a default value.
|