Knowledge Base

e_bb.php Adding BB codes to a Plugin

How to add custom bbcode to your e107 plugin
on Friday 13 July 2018
comments: 0
Adding bbcode to your e107 plugin is as simple as including a .bb file in your plugin folder. eg. mycode.bb (See e107_core/bbcodesfor sample files). If you want to include a single tag bb code (ie [hr]) then you need to add a _ before the bbcode name (ie _hr.bb).

Any bbcodes added in a plugin are available system-wide.

There are two parameters passed to a bbcode:

$parm is any text appearing after the '=' within the opening tag.
$code_text is the text appearing between the opening and closing bbcode tags.
The bbcode must return the HTML required to execute the task - this may take anything from a line or two up to tens or even hundreds of lines of code.

All the normal coding features, such as global variables, including files and the like, are available in the normal way.

To add a bbcode button to your textarea you need to create an e_bb.php file in your plugin folder. Here is an example of such a file:

Explanation:

$bb['name']: unique name. (if a .bb file is used it should match.)
$bb['onclick']: defaults to the 'addhelp' function. leave blank for simple text insertion or use 'expandit' for popups.
$bb['onclick_var']: var sent to onclick function. eg. you could send the container ID of the div to expand if expandit is used for the $bb['onclick'] parameter.
$bb['icon']: path to the button.
$bb['helptext']: the help text to display on mouseover.
$bb['function']: optional function to be called at time of loading.
$bb['function_var']: optional vars to be sent to the function. eg. for the example above the following would be executed: myFunction($myfunction_vars);

Note: To be sure that your bbcode is registered in e107, check the Preference Viewer in admin -> database and look for your file in the pref bbcode_list.
861f9fddec2c

If it is not shown, run the Plugin Scan & View in admin -> database.

E3f6fa4c9e1c

e_bb.php extension is not listed in supported extension for version 2 - reason for red checkbox

New 13.7.2018 :
e_bb.php is now supported addon in scan plugin directory