XenForo adds-on development

Assuming you have a working XenForo installation with which you want to start developing add-ons, you first need to enable debug mode through your XenForo configuration.
To do so, add the following line to /library/config.php :
$config['debug'] = 1;

Reload your Administrator Control Panel (ACP) to notice you now have a Development tab.

It comes with the following side bar:
Debug mode is essential as XenForo ACP provides developer with tools and helps guiding you through the process of developing your own add-on. You probably have notice the lack of developer documentations but in fact most of it can be found through your ACP once you've enabled debug mode.

We are now going to take you through the process of creating an add-on called Slions - Table Of Content.

Click on Create Add-on. You will get a form like the following one:
Once your add-on is created you need register listeners so that it can hook-in with XenForo core framework. Go to Code Event Listener and create a new one such as:
Notice that if you try to save your event listener without the proper PHP file being available on your server you will get the following error message:

In our case you will need to have uploaded /library/Slions/Toc/Listeners.php :
class Slions_Toc_Listeners
    * Must be registered as load_class_bb_code callback
    public static function load_class_bb_code($class, &$extend)
        // Telling XenForo we extend XenForo_BbCode_Formatter_Base with Slions_Toc_BbCode_Formatter_Base
            case 'XenForo_BbCode_Formatter_Base':
                $extend[] = 'Slions_Toc_BbCode_Formatter_Base';
        // Telling XenForo we extend XenForo_BbCode_Formatter_Wysiwyg with Slions_Toc_BbCode_Formatter_Base
            case 'XenForo_BbCode_Formatter_Wysiwyg':
                $extend[] = 'Slions_Toc_BbCode_Formatter_Base';

Last edited: