Skip to content

Adding_BB_codes_to_a_Plugin

Cameron edited this page Jan 28, 2017 · 1 revision

title: Adding BB codes to a Plugin permalink: /Adding_BB_codes_to_a_Plugin/

Adding bbcode to your e107 plugin is as simple as including a .bb file in your plugin folder. eg. mycode.bb (See e107_files/bbcodes for 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. If it is not shown, run the Plugin Scan & View in admin -> database.

Technical References

Category:Development Category:PluginWriting Category:BBCodes

Clone this wiki locally