Links

Extending core functionality (addons)

Please note: This page is under construction and has not been finished yet.

Introduction

There are several ways to extend the core functionality of e107. One of those ways is by using so-called "addons". These addons are files which reside in each plugin's folder and allow a plugin to embed itself inside e107's core pages and functions.
The addons can be recognised by their e_xxxxx.php naming format. By simply placing them inside your plugin's folder, they will be auto-detected during installation and integrated into the system.
Please note: If addons are added after plugin installation, you may need to run the
👉
"Scan plugin directories" option in Admin Area > Tools > Database.
TIP: The _blank plugin in the e107_plugins folder contains example addons that may be an easy reference for you.

Overview of all plugin addons

Name
Description
e_admin
Allows to extend areas of the Admin UI
e_bb
Allows a plugin to add customized BBCodes.
e_comment
Allows a plugin to override the default
👉
comments 'engine'
e_cron
Allows a plugin to add additional
👉
Scheduled Tasks (or 'cronjobs') to e107.
Adds custom plugin information to the dashboard of e107's admin area.
Deprecated! Use e_print instead.
e_event
Allows a plugin to easily hook into system events and trigger their own methods/functions.
Allows a plugin to generate content for the
👉
Featurebox plugin.
e_footer
Allows a plugin to include code in the footer of every page of the site
Allows a plugin developer to add their plugin as a
👉
Frontpage option.
Allows a plugin to create automated entries for the
👉
Google Sitemap plugin.
e_header
Allows a plugin developer to add data to <head> of every page.
e_help
Deprecated!
Allowed plugin developers to add information to the plugin configuration page sidebar. This has now been integrated within the Admin-UI through the renderHelp() method.
e_latest
Deprecated! Use e_dashboard instead.
e_library
Allows a plugin to include a third-party library.
e_linkgen
Deprecated!
Use e_sitelink instead.
e_list
Allows a plugin to hook into the
👉
List Latest plugin
e_mailout
Allows a plugin to use e107's mailout feature for bulk mailing.
e_menu
Provide configuration options for each instance of the plugin's menus.
e_meta
Deprecated!
Use e_header instead.
e_module
Is loaded every time the core of e107 is included and allows a developer to modify or define code which should be loaded prior to the header or anything that is sent to the browser as output.
e_notify
Adds a plugin to the notifications section in e107's admin area.
e_output
Allows a plugin to hook into all pages at the end (after closing </html>)
e_parse
Allows a plugin to hook into e107's parser methods
e_print
Allows a plugin developer to specify content that is displayed in printer-friendly format.
e_rss
Adds a plugin to the RSS plugin, and generates RSS feeds.
e_related
Adds a plugin to the search which generates 'related' links in news items and pages.
e_search
Adds a plugin to the
👉
Search page.
Allows a plugin to make their shortcodes available to core templates and templates of other plugins.
Allows a plugin to automatically generate
👉
Navigation links
e_status
Deprecated! Use e_dashboard instead.
e_tohtml
Deprecated! Use e_parse instead.
e_upload
Allows a plugin to set categories for
👉
Public Uploads
e_url
Provides a simple way to add mod-rewrite redirects to a plugin's page. Used to create search-engine-friendly URLs through the e107::url() method.
e_user
Adds information about a specific user to the user's profile page, allows to add fields to the user settings page and allows to specify a routine that is run upon user deletion.

Plugin addons

👍
Be sure to replace plugindir with your plugin's directory name in all examples below.

e_admin.php

TODO: Add example. See social plugin for an example.

e_bb.php

TODO: Add example.

e_comment.php

TODO: Add example. See social plugin for an example.

e_cron.php

This addon allows a plugin to add additional scheduled task options to e107. (see Admin Area > Tools > Scheduled Tasks).

Example:

class plugindir_cron // plugin-folder name + '_cron'
{
function config() // Setup
{
$cron = array();
$cron[] = array(
'name' => "Name of my function", // Displayed in admin area. .
'function' => "myFunction", // Name of the function which is defined below.
'category' => 'mail', // Choose between: mail, user, content, notify, or backup
'description' => "Description of what my function does" // Displayed in admin area.
);
return $cron;
}
public function myFunction()
{
// Do something.
}
}

e_dashboard.php

This addon adds custom plugin information to the dashboard of e107's admin area. The 'latest', 'status' and 'website stats' areas may all contain information from your plugin.
Previously, the e_latest and e_status addons were used separately for this. They have now been incorporated into the e_dashboard addon.

Example:

class plugindir_dashboard // plugin-folder name + '_dashboard'
{
private $title; // dynamic title.
function chart()
{
$config = array();
$config[] = array(
'text' => $this->activity(),
'caption' => $this->title,
);
return $config;
}
/**
* Non-functional example.
*/
function activity()
{
// do something
}
function status() // Status Panel in the admin area
{
$var[0]['icon'] = "<img src='".e_PLUGIN."plugindir/images/blank_16.png' alt='' />";
$var[0]['title'] = "My Title";
$var[0]['url'] = e_PLUGIN_ABS."plugindir/plugin.php";
$var[0]['total'] = 10;
return $var;
}
function latest() // Latest panel in the admin area.
{
$var[0]['icon'] = "<img src='".e_PLUGIN."plugindir/images/blank_16.png' alt='' />";
$var[0]['title'] = "My Title";
$var[0]['url'] = e_PLUGIN_ABS."plugindir/plugin.php";
$var[0]['total'] = 10;
return $var;
}
}

e_emailprint.php

Deprecated! This addon has been deprecated. Use e_print.php instead.

e_event.php

This addon allows a plugin to easily hook into system events and trigger their own methods and functions using data provided by those events.
You can make use of the event methods and event triggers.

Example:

class plugindir_event // plugin-folder + '_event'
{
function config()
{
$event = array();
// Hook into a core event, in this case "login".
$event[] = array(
'name' => "login", // when this is triggered...
'function' => "myfunction", // ..run this function (see below).
);
// Hook into a custom plugin event (created by that plugin author)
$event[] = array(
'name' => "pluginfolder_customevent", // hook into a custom plugin event
'function' => "otherfunction", // ..run another function (see below).
);
return $event;
}
function myfunction($data) // the method to run.
{
// var_dump($data);
}
function otherfunction($data) // the method to run.
{
// var_dump($data);
}
}

e_featurebox.php

TODO: Add example.

e_footer.php

This addon allows a plugin to include code in the footer of every page of the site.
Please find an example in the "tinymce4" plugin.

e_frontpage.php

This addon allows a plugin developer to add their plugin as a
👉
Frontpage option.

Example:

class plugindir_frontpage // plugin-folder + '_frontpage'
{
// Option 1: individual item
function config()
{
$frontPage = array(
'page' => '{e_PLUGIN}_blank/_blank.php',
'title' => LAN_PLUGIN__BLANK_NAME
);
return $frontPage;
}
// Option 2: multiple items
function config()
{
$config = array();
$config['title'] = LAN_PLUGIN__BLANK_NAME;
$config['page'] = array(
0 => array(
'page' => '{e_PLUGIN}_blank/_blank.php',
'title'=>'Main Page'
),
);
return $config;
}
}

e_gsitemap.php

TODO: Add example. See "news" plugin folder for an example.

e_header.php

This addon allows a plugin developer to add data to the <head> of every page. This file is loaded in the header of each page of your site. ie. Wherever you see require_once(HEADERF) in a script. Typically you would use one or all of the following functions within this file: e107::js(), e107::css() or e107::meta()
Warning: Output should never be echoed or printed from this file!

Example:

if(deftrue('USER_AREA')) // prevents inclusion of JS/CSS/meta in the admin area.
{
e107::js('_blank', 'js/blank.js'); // loads e107_plugins/_blank/js/blank.js on every page.
e107::css('_blank', 'css/blank.css'); // loads e107_plugins/_blank/css/blank.css on every page
e107::meta('keywords', 'blank,words'); // sets meta keywords on every page.
}

e_help.php

Deprecated! This addon allowed plugin developers to add information to the plugin configuration page sidebar. This has now been integrated within the Admin-UI through the renderHelp() method.

e_latest.php

Deprecated! This addon has been deprecated. Use e_dashboard.php instead.

e_library.php

Please find an example in the "_blank" plugin.

e_linkgen.php

Deprecated! This addon has been deprecated. Use e_sitelink.php instead.

e_list.php

TODO: Add example.

e_mailout.php

This addon allows a plugin to use e107's mailout feature for bulk mailing.
Please find an example in the "newsletter" plugin.

e_menu.php

This addon provides configuration options for each instance of the plugin's menus.
The e_menu.php addon is a replacement for the old config.php file used in e107 v1.x.

Example:

class plugindir_menu // plugin-folder name + '_menu'
{
function __construct()
{
}
/**
* Configuration Fields.
* See Admin-UI field configurations (https://devguide.e107.org/plugin-development/admin-ui)
* @return array
*/
public function config($menu='')
{
$fields = array();
$fields['blankCaption'] = array('title' => "Caption", 'type' => 'text', 'multilan'=>true, 'writeParms'=>array('size'=>'xxlarge'));
$fields['blankCount'] = array('title' => "Enabled", 'type' => 'number');
$fields['blankCustom'] = array('title' => "Enabled", 'type' => 'method'); // see below.
return $fields;
}
}
// optional - for when using custom methods above.
class plugindir_menu_form extends e_form
{
function blankCustom($curVal)
{
$frm = e107::getForm();
$opts = array(1, 2, 3, 4);
$frm->select('blankCustom', $opts, $curVal);
}
}

e_meta.php

Deprecated! This addon has been deprecated. Use e_header.php instead.

e_module.php

This addon is loaded every time the core of e107 is included. ie. Wherever you see require_once("class2.php") in a script.
It allows a developer to modify or define constants, parameters etc. which should be loaded prior to the header or anything that is sent to the browser as output. It may also be included in Ajax calls.

e_notify.php

This addon adds the plugin to the
👉
Notify section in the Admin Area and allows a plugin to send notifications.

Example:

class plugindir_notify extends notify // plugin-folder name + '_notify'
{
function config()
{
$config = array();
$config[] = array(
'name' => "New Trigger Name", // Displayed in admin area.
'function' => "plugindir_mytrigger",
'category' => ''
);
return $config;
}
function plugindir_mytrigger($data)
{
$message = print_a($data,true);
$this->send('plugindir_mytrigger', "My Subject", $message);
}
}
The notification can then be triggered by using:
e107::getEvent()->trigger("plugindir_mytrigger", $data);

e_output.php

This addon allows to hook into all pages at the very end (after the closing </html>). This is useful for example when capturing
👉
output buffering.

e_parse.php

This addon allows to hook into e107's parser methods

Example:

class plugindir_parse // plugin-folder name + '_parse'
{
/**
* Process a string before it is sent to the browser as html.
* @param string $text html/text to be processed.
* @param string $context Current context ie. OLDDEFAULT | BODY | TITLE | SUMMARY | DESCRIPTION | WYSIWYG etc.
* @return string
*/
function toHTML($text, $context = '')
{
$text = str_replace('****', '<hr>', $text);
return $text;
}
/**
* Process a string before it is saved to the database.
* @param string $text html/text to be processed.
* @param array $param nostrip, noencode etc.
* @return string
*/
function toDB($text, $param = array())
{
$text = str_replace('<hr>', '****', $text);
return $text;
}
}

e_print.php

This addon allows a plugin developer to specify content that is displayed in printer-friendly format

Example:

class plugindir_print // plugin-folder + '_print'
{
public function render($parm)
{
$text = "Hello {$parm}!";
return $text;
}
}

e_rss.php

This addon adds the plugin to the RSS plugin, and generates RSS feeds for the plugin.

Example:

class plugindir_rss // plugin-folder name + '_rss'
{
/**
* Admin RSS Configuration
*/
function config()
{
$config = array();
$config[] = array(
'name' => 'Feed Name',
'url' => 'blank',
'topic_id' => '',
'description' => 'This is the RSS feed for the blank plugin', // that's 'description' not 'text'
'class' => e_UC_MEMBER,
'limit' => '9'
);
return $config;
}
/**
* Compile RSS Data
* @param array $parms
* @param string $parms['url']
* @param int $parms['limit']
* @param int $parms['id']
* @return array
*/
function data($parms=array())
{
$sql = e107::getDb();
$rss = array();
$i = 0;
if($items = $sql->select('blank', "*", "blank_field = 1 LIMIT 0,".$parms['limit']))
{
while($row = $sql->fetch())
{
$rss[$i]['author'] = $row['blank_user_id'];
$rss[$i]['author_email'] = $row['blank_user_email'];
$rss[$i]['link'] = "_blank/_blank.php?";
$rss[$i]['linkid'] = $row['blank_id'];
$rss[$i]['title'] = $row['blank_title'];
$rss[$i]['description'] = $row['blank_message'];
$rss[$i]['category_name'] = '';
$rss[$i]['category_link'] = '';
$rss[$i]['datestamp'] = $row['blank_datestamp'];
$rss[$i]['enc_url'] = "";
$rss[$i]['enc_leng'] = "";
$rss[$i]['enc_type'] = "";
$i++;
}
}
return $rss;
}
}

e_related.php

This addon adds the plugin to the search which generates 'related' links in news items and pages of e107.

Example:

class plugindir_related // plugin-folder name + '_menu'
{
function compile($tags,$parm=array())
{
$sql = e107::getDb();
$items = array();
$tag_regexp = "'(^|,)(".str_replace(",", "|", $tags).")(,|$)'";
$query = "SELECT * FROM `#_blank` WHERE _blank_id != ".$parm['current']." AND _blank_keywords REGEXP ".$tag_regexp." ORDER BY _blank_datestamp DESC LIMIT ".$parm['limit'];
if($sql->gen($query))
{
while($row = $sql->fetch())
{
$items[] = array(
'title' => varset($row['blank_title']),
'url' => e107::url('other',$row),
'summary' => varset($row['blank_summary']),
'image' => '{e_PLUGIN}_blank/images/image.png'
);
}
return $items;
}
}
}

e_search.php

This addon adds the plugin to the 'search page' of e107.

Example:

class plugindir_search extends e_search // plugin-folder name + '_search'
{
function config()
{
$search = array(
'name' => "Blank Plugin",
'table' => 'blank',
'advanced' => array(
'date' => array('type' => 'date', 'text' => LAN_DATE_POSTED),
'author'=> array('type' => 'author', 'text' => LAN_SEARCH_61)
),
'return_fields' => array('blank_id', 'blank_nick', 'blank_message', 'blank_datestamp'),
'search_fields' => array('blank_nick' => '1', 'blank_message' => '1'), // fields and weights.
'order' => array('blank_datestamp' => 'DESC'),
'refpage' => 'chat.php'
);
return $search;
}
/* Compile Database data for output */
function compile($row)
{
preg_match("/([0-9]+)\.(.*)/", $row['blank_nick'], $user);
$res = array();
$res['link'] = e_PLUGIN."blank_menu/_blank.php?".$row['blank_id'].".fs";
$res['pre_title'] = LAN_SEARCH_7;
$res['title'] = $user[2];
$res['summary'] = $row['blank_message'];
$res['detail'] = e107::getParser()->toDate($row['blank_datestamp'], "long");
return $res;
}
/**
* Optional - Advanced Where
* @param $parm - data returned from $_GET (ie. advanced fields included. in this case 'date' and 'author' )
*/
function where($parm=null)
{
$tp = e107::getParser();
$qry = "";
if (vartrue($parm['time']) && is_numeric($parm['time']))
{
$qry .= " blank_datestamp ".($parm['on'] == 'new' ? '>=' : '<=')." '".(time() - $parm['time'])."' AND";
}
if (vartrue($parm['author']))
{
$qry .= " blank_nick LIKE '%".$tp->toDB($parm['author'])."%' AND";
}
return $qry;
}
}

e_shortcode.php

This addon allows a plugin to make their shortcodes available to core templates and templates of other plugins.
It's content is identical to that of a regular shortcode class except that all the methods must follow the following naming convention: sc_plugindir_name()
The $override property can be used to override existing core/plugin shortcodes. When set to true existing core/plugin shortcodes matching methods below will be overridden.

Example:

class plugindir_shortcodes extends e_shortcode
{
public $override = false; // when set to true, existing core/plugin shortcodes matching methods below will be overridden.
// Example: {PLUGINDIR_CUSTOM} shortcode - available site-wide.
function sc_plugindir_custom($parm = null) // Naming: "sc_" + [plugin-directory] + '_uniquename'
{
return "Hello World!";
}
}

e_sitelink.php

This addon adds a sitelink sublink-generating function for your plugin. An example is auto-generated navigation drop-down menus for 'latest articles'.

Example:

class plugindir_sitelink // plugin-folder name + '_sitelink'
{
function config()
{
$links = array();
$links[] = array(
'name' => 'Drop-Down MegaMenu',
'function' => 'megaMenu' // see method below
);
$links[] = array(
'name' => "Drop-Down Links",
'function' => "myCategories" // see method below
);
return $links;
}
function megaMenu()
{
$text = '<div class="dropdown-menu mega-dropdown-menu">
<div class="container-fluid2">
<ul class="nav-list list-inline">
<li><a data-filter="#" href="#"><img src="#><span>#</span></a></li>
<li><a data-filter="#" href="#"><img src="#><span>#</span></a></li>
<li><a data-filter="#" href="#"><img src="#><span>#</span></a></li>
<li><a data-filter="#" href="#"><img src="#><span>#</span></a></li>
<li><a data-filter="#" href="#"><img src="#><span>#</span></a></li>
<li><a data-filter="#" href="#"><img src="#><span>#</span></a></li>
</ul>
</div>
</div>
';
return $text;
}
function myCategories()
{
$sublinks = array();
e107::getDb()->select("blank","*","blank_id != '' ");
while($row = e107::getDb()->fetch())
{
$sublinks[] = array(
'link_name' => e107::getParser()->toHTML($row['blank_name'],'','TITLE'),
'link_url' => e107::url('_blank', 'other', $row),
'link_description' => '',
'link_button' => $row['blank_icon'],
'link_category' => '',
'link_order' => '',
'link_parent' => '',
'link_open' => '',
'link_class' => e_UC_PUBLIC
);
}
return $sublinks;
}
}