XF 1.3 Custom BB Codes

Some of you may have spotted this in a previous Have You Seen, but today we're going to look at XenForo 1.3's custom BB code support in detail.

At a high level, custom BB codes let you define BB codes to fit your site's needs. This allows you to give your users more options for mark up, without opening up arbitrary HTML and the various issues (security and otherwise) that come with that. A BB code may take an "option" parameter if needed, such as in [COLOR=option]...[/COLOR].

Basic Options

Let's look at the main BB code creation form. It's a biggie:

ss-2014-01-07_15-54-06.webp


This is just the "basic" fields. We'll get into the advanced stuff in a bit.

Many of these fields should be self explanatory. The title/description mostly relate to the help page, as well the example. Otherwise, you define how the tag is used -- if it takes an option or not (or optionally) and how the HTML replacement is done. If you wish to callback to a PHP file, you can.

Another option to note is the control over whether this BB code can be used in signatures. While custom BB codes don't have the full control of signature permissions like the standard codes, this can be used to limit certain codes in signatures to prevent abuse.

Advanced Options

Now, we have a bunch of other options which you don't necessarily need to adjust:

ss-2014-01-07_15-54-18.webp


On the advanced page, you can limit the option to expected formats. This is used in color, font, and size tags for example. You can also change the parsing rules within the tag, such as disabling smilies and other BB codes; you can see this in the [CODE] tag for example.

You can also add an icon to the editor to make it easier to add your code. If you've configured smilies, you'll be familiar with these options. (Note that this will just add a simple icon that when clicked makes it easy to insert the tag; more extensive integration would require custom JavaScript.)

Finally, in a few rare cases, you might want to use specific alternative replacements based on the context. Notably, this can be done in HTML emails (by default, the quote tag is different) or when rendering to pure text (quotes and images are different, amongst other things).

Add-ons, Importing, and Exporting

You might have noticed the option to select an add-on on the BB code creation form. Like various other types of content, you can assign a custom BB code to an add-on and it will be created when the add-on is installed and remove when it's uninstalled. (This is only available in debug mode.)

However, like smilies, a selection of BB codes can also be individually exported and then imported, independent of the add-on system. This should make sharing BB codes (or BB code sets) easier. (Note that BB codes that are attached to an add-on cannot be exported independent of the add-on.)



While this is certainly not a revolutionary feature, we're sure this will give admins more control over their site and allow you and your users to format messages the way you want.
 
This can support tables, and for RTL boards we can finally write normally in English without the punctuation to go to the wrong side.
 
Can someone list a few innovative uses of this feature. The only thing that comes to my mind is ability to add 'Tables' & a spoiler tag. :coffee:
 
A spoiler code can be implemented without the need for JavaScript. But either way, it can still easily be added via a code manager such as this.
 
Really good stuff, will allow us to remove an add-on and I hope/think it will enable creation of more custom BB-examples for us coding illiterates.

I would love an really easy to use BB-code for tables. Missing in most forum-software as an standard option
 
I will be more than happy to use this so that I can finally uninstall @cclaerhout BB Code addon. My site's members rarely use BB Codes anyway. I will need a html or raw bb code so that I can embed videos. Would someone be able to create a raw or html bb code with this feature? Also I would need that bb code to only be able to be used by premium members and moderators. So looks like I might have to keep cclaerhouts addon after all.
 
I will be more than happy to use this so that I can finally uninstall @cclaerhout BB Code addon. My site's members rarely use BB Codes anyway. I will need a html or raw bb code so that I can embed videos. Would someone be able to create a raw or html bb code with this feature? Also I would need that bb code to only be able to be used by premium members and moderators. So looks like I might have to keep cclaerhouts addon after all.
A RAW or html bbcode for spoiler is good too... a spoiler inside spoiler!
 
I will be more than happy to use this so that I can finally uninstall @cclaerhout BB Code addon. My site's members rarely use BB Codes anyway. I will need a html or raw bb code so that I can embed videos. Would someone be able to create a raw or html bb code with this feature? Also I would need that bb code to only be able to be used by premium members and moderators. So looks like I might have to keep cclaerhouts addon after all.


May just need to use a php callback. Anything should be possible with this system. Permission/User Group checks may be a little more difficult than desired but between the regex options and php callbacks, you're set.
 
Back
Top Bottom