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.
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
Plugin addons
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:
classplugindir_cron// plugin-folder name + '_cron'{functionconfig() // 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; }publicfunctionmyFunction() {// 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:
classplugindir_dashboard// plugin-folder name + '_dashboard'{private $title; // dynamic title.functionchart() { $config =array(); $config[] =array('text'=>$this->activity(),'caption'=>$this->title, );return $config; }/** * Non-functional example. */functionactivity() {// do something }functionstatus() // 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; } functionlatest() // 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.
classplugindir_event// plugin-folder + '_event'{functionconfig() { $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; }functionmyfunction($data) // the method to run. {// var_dump($data); }functionotherfunction($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.
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 pagee107::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:
classplugindir_menu// plugin-folder name + '_menu'{function__construct() { }/** * Configuration Fields. * See Admin-UI field configurations (https://devguide.e107.org/plugin-development/admin-ui) * @returnarray */publicfunctionconfig($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.classplugindir_menu_formextendse_form{functionblankCustom($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.
classplugindir_parse// plugin-folder name + '_parse' {/** * Process a string before it is sent to the browser as html. * @paramstring $text html/text to be processed. * @paramstring $context Current context ie. OLDDEFAULT | BODY | TITLE | SUMMARY | DESCRIPTION | WYSIWYG etc. * @returnstring */functiontoHTML($text, $context ='') { $text =str_replace('****','<hr>', $text);return $text; }/** * Process a string before it is saved to the database. * @paramstring $text html/text to be processed. * @paramarray $param nostrip, noencode etc. * @returnstring */functiontoDB($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
This addon adds the plugin to the search which generates 'related' links in news items and pages of e107.
Example:
classplugindir_related// plugin-folder name + '_menu'{functioncompile($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:
classplugindir_searchextendse_search// plugin-folder name + '_search'{functionconfig() { $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 */functioncompile($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' ) */functionwhere($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:
classplugindir_shortcodesextendse_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.functionsc_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'.
Deprecated!
This addon has been deprecated. Use e_dashboard.php instead.
e_tohtml.php
Deprecated!
This addon has been deprecated. Use e_parse.php instead.
e_upload.php
TODO: Add example.
e_url.php
This addon provides a simple way to add mod-rewrite redirects to the plugin's pages, without having to edit the .htaccess file. This addon is used to create Search-Engine-Friendly (SEF) URLs through the e107::url() method.
classplugindir_url// plugin-folder name + '_url' {functionconfig() { $config =array(); $config['index'] =array('regex'=>'^_blank/?$',// matched against url, and if true, redirected to 'redirect' below.'sef'=>'_blank',// used by e107::url(); to create a url from the db table.'redirect'=>'{e_PLUGIN}_blank/blank.php',// file-path of what to load when the regex returns true. ); $config['other'] =array( 'alias' => '_blank', // the below {alias} is substituted with this value. Default alias '_blank', w which can be customized within the admin area.
'regex'=>'^{alias}/other/?$',// matched against url, and if true, redirected to 'redirect' below.'sef'=>'{alias}/other/',// used by e107::url(); to create a url from the db table.'redirect'=>'{e_PLUGIN}_blank/_blank.php?other=1',// file-path of what to load when the regex returns true. );return $config; }}
e_user.php
This addon allows to:
add information about a specific user to the user's profile page
add and save fields to the user configuration page (/usersettings.php)
specify a routine that is run upon user deletion
Example:
classplugindir_user// plugin-folder + '_user'{ /** * Display information on the user profile page */functionprofile($udata) { $var =array(0=>array('label'=>"Label",'text'=>"Some text to display",'url'=> e_PLUGIN_ABS."_blank/blank.php") );return $var; }/** * This allows to show field on the usersettings.php page * The same field format as admin-ui, with the addition of 'fieldType', 'read', 'write', 'appliable' and 'required' as used in extended fields table.
* * @returnarray */functionsettings() { $fields =array(); $fields['field1'] =array('title'=>"Field 1",'fieldType'=>'varchar(30)','read'=> e_UC_ADMIN,'write'=> e_UC_MEMBER,'type'=>'text','writeParms'=>array('size'=>'xxlarge') ); $fields['field2'] =array('title'=>"Field 2",'fieldType'=>'int(2)','type'=>'number','data'=>'int' ); $fields['field3'] =array('title'=>"Field 3",'fieldType'=>'int(1)','type'=>'method',// see method below.'data'=>'str','required'=>true ); return $fields; }/** * This routine is run upon user deletion * Experimental and subject to change without notice. * @returnmixed */functiondelete() { $config['user'] =array('user_id'=>'[primary]','user_name'=>'[unique]','user_loginname'=>'[unique]','user_email'=>'[unique]','user_ip'=>'',// etc.'WHERE'=>'user_id = '.USERID,'MODE'=>'update' ); $config['user_extended'] =array('WHERE'=>'user_extended_id = '.USERID,'MODE'=>'delete' );return $config; }}// (plugin-folder)_user_form - only required when using custom methods.classplugindir_user_formextendse_form{// user_plugin_(plugin-folder)_(fieldname)publicfunctionuser_plugin_plugindir_field3($curVal, $mode, $att =array()) { $opts =array(1,2,3,4);return$this->select('user_plugin_plugindir_field3', $opts, $curVal); }}