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.
 
Now, this is epic! 1.3 with all these goodies is turning out to indeed be a step above 1.2 which I thought would be hard because 1.2 was a massive massive updated from 1.1, responsive design, editor etc. 1.3 is shaping out to have many many useful features as well, love the ability to add icons.

Now, I shall only need to implement the spoiler code again, for which I do have one doubt. @Jeremy I currently use your add-on for the spoiler code (Custom BBCode Manager), its the same syntax . Once 1.3 is out and we upgrade (and uninstall the add-on) and implement a new spoiler code via the built in method, will all the old
codes remain the same or will they break?
 
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.
No, regex will do nothing and a simple callback will be not enough. With XenForo 1.x.x you will need workarounds to try to imitate view and parsing permissions with Bb Codes. I think for clean native permissions the code architecture would need to be redone, which might be quite a massive work.

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.
This is a good thing XenForo finally gets a default Bb Codes Manager. Now, for my own needs, I still need to access templates the easiest way possible and more over, I need a Buttons Manager to deal with my editor configs, button position & permissions and buttons returns, so the bbm development will still go on, but that's not a surprise. I just hope, I would not have to spend too much time to adapt the code to the new formatter, but I will see this on time.

Anyway, good work, especially for the addon integration.
 
I see the "If provided, an icon to insert this BB code will appear in the editor." and this will be great, but will there be a function to sort this custom BB codes in the editor too?

EDIT:
I need a Buttons Manager to deal with my editor configs, button position & permissions and buttons returns, so the bbm development will still go on
Thanks Cédric, this is what I need too
 
I honestly cannot see this as being useful on my site - UNLESS it will allow my users to "simply" choose size and color of their text "one time" and become default there after in a message. Unless your a professional forum user - stuff like this is a bit "techie." If it requires them adding text between codes it will not be used on my forum unfortunately.
 
It will not allow you to set default styling on posts.

Also, with the WYSIWYG editor, most of the codes are obscured and not shown to the user.
 
BB code has been in use for decades on forums.
It's fairly standard functionality.

Your users use it all the time when they quote, embolden, italicise, etc.
 
replace Jeremy's BBCode manager that is used by many people and a standard function in VB
Indeed it will! Thanks to Jeremy for his excellent add-on that has filled the gap for so long. :)

@tommydamic68 on my site we use spoilers at times to hide plotlines from the games we play so as not to give away what happens to those who haven't played them yet. The spoiler tag is also useful for putting images in that might be considered not safe for work. With an appropriate label on the spoiler tag, it means you won't get surprised by an image of Kelly Brook in a bikini whilst your boss is glancing at your screen as they walk by. :eek:

As others have mentioned, there's a whole variety of new BBCodes that can be created, so forum members will be able to use highlighters, tables, raw html, justification and so on.

I'm betting that within a few weeks of you installing Xenforo 1.3, you'll be using custom BBCodes and posting on here for support on creating/using them. ;)
 
Nice! I have a few new codes in mind I'd like to put into use. :)

I don't know if it's related, but I have to go make a suggestion regarding BB Codes that would be permissions-based. (Basically, we'd want to be able to revoke use of the IMG code for a small number of users who are abusing it.)
 
Indeed it will! Thanks to Jeremy for his excellent add-on that has filled the gap for so long. :)

@tommydamic68 on my site we use spoilers at times to hide plotlines from the games we play so as not to give away what happens to those who haven't played them yet. The spoiler tag is also useful for putting images in that might be considered not safe for work. With an appropriate label on the spoiler tag, it means you won't get surprised by an image of Kelly Brook in a bikini whilst your boss is glancing at your screen as they walk by. :eek:

As others have mentioned, there's a whole variety of new BBCodes that can be created, so forum members will be able to use highlighters, tables, raw html, justification and so on.

I'm betting that within a few weeks of you installing Xenforo 1.3, you'll be using custom BBCodes and posting on here for support on creating/using them. ;)
Ok @Martok- thanks! I do hope it serves a purpose or two for me. :D Still waiting for news to see if or what 1.3 will bring to me to tickle my fancy...:p
 
Top Bottom