1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

XF 1.3 Custom BB Codes

Discussion in 'Have You Seen...?' started by Mike, Jan 7, 2014.

  1. Mike

    Mike XenForo Developer Staff Member

    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:


    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:


    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.
    Camper, dwdmadmac, lantek and 98 others like this.
  2. Slavik

    Slavik XenForo Moderator Staff Member

    Good job :)
    Ryan_, whynot, Claudio and 1 other person like this.
  3. Andrej

    Andrej Well-Known Member

  4. John L.

    John L. Well-Known Member

    Get myself some spoiler action going :)
    BassMan likes this.
  5. Jeremy

    Jeremy Well-Known Member

    Jeremy breathes a sign of relief.
    (y) Good job, Mike & Kier!
    Russ and Divvens like this.
  6. Liam W

    Liam W Well-Known Member


    I like what I see :)

    No video though :( You need to get over your fear @Mike ;)

    This is a highly requested feature, and I'm going to stop now before I start repeating myself!

    Last edited: Jan 7, 2014
    bobs409, MadiXIV, Jay and 1 other person like this.
  7. Moshe1010

    Moshe1010 Well-Known Member

    This can support tables, and for RTL boards we can finally write normally in English without the punctuation to go to the wrong side.
    MadiXIV likes this.
  8. DJ XtAzY

    DJ XtAzY Active Member

    Now I wonder if these custom BB codes can be tied to usergroup permissions.
    MadiXIV, Ryan_, Adam Howard and 5 others like this.
  9. Andy.N

    Andy.N Well-Known Member

    Is it possible to use Fontawesome Icon for editor icon when we add a new bbcode?
    Alfa1 likes this.
  10. TheBigK

    TheBigK Well-Known Member

    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:
  11. Jeremy

    Jeremy Well-Known Member

  12. Luxus

    Luxus Well-Known Member

    A spoiler bbcode would require custom javascript, no?
  13. Jeremy

    Jeremy Well-Known Member

    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.
  14. shorepower

    shorepower Active Member

    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
  15. ::abdo::

    ::abdo:: Member

    very good
  16. DRE

    DRE Well-Known Member

    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.
  17. AndyB

    AndyB Well-Known Member

    This is fantastic, Mike and Kier.

    One less custom add-on I will be able to remove.
  18. Sheratan

    Sheratan Well-Known Member

    A RAW or html bbcode for spoiler is good too... a spoiler inside spoiler!
    DRE likes this.
  19. Rambro

    Rambro Well-Known Member

    Thank you based god
    TeflonDon, NixFifty and DRE like this.
  20. Daniel Hood

    Daniel Hood Well-Known Member

    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.

Share This Page