-
Notifications
You must be signed in to change notification settings - Fork 10
Extensibility Basics
This document is designed to explain the concepts of building an ASB module in its most basic form. For further details, view the entire list of extensibility documents: Extensibility Docs
For a module to be accepted by Advanced Sidebox as a valid add-on, it must meet these criteria:
- A file must exist in the modules directory (inc/plugins/asb/modules) named
example.php
and - This file must be a valid PHP file with two functions:
asb_example_info
andasb_example_get_content
replace example
with the base_name for your module
If everything is in order, Advanced Sidebox will attempt to load this add-on.
The _info()
function provides ASB with information used to build the resulting HTML content. This includes properties, settings, templates, etc.
(Keep in mind that we are still using the example
base-name from the previous example).
In the _info()
function you will need to name and optionally describe your module and define its type.
function asb_example_info()
{
return array(
'title' => 'Your Title Here',
'description' => 'A description here', // optional
'version' => '1',
'wrap_content' => true,
'compatibility' => '4.0',
);
}
-
title
- (string) - serves as the default title for side boxes created with this add-on -
version
- (string) - required to maintain module upgrades -
wrap_content
- (bool) - false to produce a side box without the default table and expander, true (default) to allow ASB to wrap the side box in a default tborder class table structure -
compatibility
- (string) - since 2.1 distinguishes between earlier modules that are no longer compatible with this plugin.
-
description
- (string) - is used in the module manager info -
settings
- (array) an array of MyBB standard ACP setting definitions -
installData
- (array) an array of components to install for the module, including templates and settings -
xmlhttp
- (bool) true to add the ability of AJAX refresh to the module -
removedTemplates
- (array) - for module upgrades that remove previously used templates, an array of the template names -
author
- (string) - module developer -
author_site
- (string) - author website -
module_site
- (string) - module website, repository link, etc. -
scripts
- (array) - array of filenames for external JavaScript files to include from./jscripts/asb
-
debugMode
- (bool) -true
to attempt module upgrade for every page load,false
(default) to only upgrade when the module version is incremented
Each ASB module must also contain a _get_content()
function. This is the main function used to display the add-on module's side box content. Simply return content from your function and ASB will handle the rest.
This is an example of a simple module's _get_content()
function (staying with the example
base name):
function asb_example_get_content($settings)
{
return <<<EOF
<div class="trow1">Your content here.</div>
EOF;
}
-
$settings
- (array) - used when the add-on module has individual settings, passes an associative array of add-on settings -
$script
- (string) - the original location the side box was displayed on with environment parameters-- useful for XMLHTTP routines that redirect -
$dateline
- (string) - is the UNIX datetime stamp denoting the creation time of the sidebox (page load/update) -
$template_var
- (string) - is the encoded base name of the add-on module use to create the unique ID for each box
At the beginning of your module file, use this code to make sure that the file is being required by a valid MyBB instance and that Advanced Sidebox is active.
if (!defined("IN_ASB") ||
!defined('IN_MYBB')) {
die('You are not allowed to directly access this resource.');
}
For a simple example of the basics, look here: Simple Module Example