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.
 
With custom BB codes would it be possible to create fields that you can later search in a search form.

For instance if you would be running a forum for cars having three codes

Car manufacturer
Model
Model year


Free format but these fields would be searchable and you would then be able to find posts that contains the any of these fields?

Hope the question is somewhat clear
 
Any chance we'll be able to create a drop-down icon with a list of pre-defined parameters (like the drop-down for the font selector)?
 
Media BB code is, err, BB code.
So you can already do what you need to with the existing functionality.
Yeah but @caliman quoted a post of mine that wasn't originally about regular bb code media.

It was about permissions-based bb code. That can't be done in the existing bb code or this upcoming bb code manager.

I'd have to use one of the following addons for that:

1. http://xenforo.com/community/resources/bbcodes-buttons-manager.1731/
2. http://xenforo.com/community/resources/html-bbcode-permission-protected.731/
3. http://xenforo.com/community/resources/vfcoders-hide-hack-v1.2484/
4. http://xenforo.com/community/resources/hide-bb-code-bb-codes-buttons-manager.2636/
 
The BB code functions look fantastic. Building my new site there is some integration I want to do with my site's data using BB code and now I won't have to completely create my own!
 
Because it's relevant, I'll quote myself here.

@Mike / @Kier

This is one of the (nearly) top 10 most liked suggestions.

Seems like it might go well with the recently announced BB Code Manager.

It would make a useful "example" BB Code for that system, and I imagine that most people would struggle to move away from their current add-on based BB Code Managers which (to my knowledge) both include spoiler code by default.
 
Top Bottom