Creating an e107 plugin

Extending core functionality

e107 plugin "addons" are files which reside in each plugin's folder and allow a plugin to embed itself inside e107's core pages and functions.
You can recognize these files by their e_xxxxx.php naming format.
By simply placing any or all of the file types below inside your plugin's folder, they will be auto-detected during installation and integrated into the system.
If added after installation you may need to run the Scan Plugin Folders option in admin -> Databases.

e_cron.php

Allows a plugin to add additional scheduled task options to e107. (see admin -> Scheduled Tasks)
Be sure to replace plugindir with your plugin's directory name. eg. class faqs_cron

		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

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.
See e107_plugins/forum/e_dashboard.php for an example of usage.

e_event.php (as of e107 v2.1.2)

Allows a plugin to easily hook into system events and trigger their own methods/functions using data provided by those events. (more coming soon)

e_header.php

Allows a plugin developer to add data to the 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.
It is used to place elements inside the html tags.
Typically you would use one or all of the following functions within this file: e107::js(), e107::css() or e107::meta().
Output should never be echoed or printed from this file.

e_latest.php

Deprecated. Use e_dashboard.php instead.

e_mailout.php

Allows your plugin to use e107's mailout feature for bulk mailing.
See e107_plugins/newsletter/e_mailout.php for an example.

e_menu.php

Provide configuration options for each instance of your plugin's menus. Examples can be found in e107_plugins/banner/e_menu.php and e107_plugins/news/e_menu.php

(This is a replacement for the old config.php file used in v1.x)

e_module.php

This file 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_search.php

Adds your plugin to the 'search page' of e107.
See e107_plugins/chatbox_menu/e_search.php for an example.

e_meta.php

Deprecated. Use e_header.php instead.

e_notify.php

Adds your plugin to the email notifications admin area. Replace mytrigger with a unique name of your own, and myplugin with your plugin folder.

		class myplugin_notify extends notify // plugin-folder + '_notify' 
{		
	function config()
	{
		
		$config = array();
	
		$config[] = array(
			'name'			=> "New Trigger Name", // Displayed in admin area. 
			'function'		=> "myplugin_mytrigger",
			'category'		=> ''
		);	
		
		return $config;
	}
	
	function myplugin_mytrigger($data) 
	{
	
		$message = print_a($data,true);
		
		$this->send('myplugin_mytrigger', "My Subject", $message);
	}
	
}

Then add the following to your script when you want to trigger it.

		e107::getEvent()->trigger("myplugin_mytrigger", $data);



e_status.php

Deprecated. Use e_dashboard.php instead.

e_rss.php

Adds your plugin to the RSS plugin, and generates RSS feeds for your plugin.

		class chatbox_menu_rss // plugin-folder + '_rss' 
{
    /**
     * Admin RSS Configuration 
     */        
    function config() 
    {
        $config = array();
    
        $config[] = array(
            'name'            => 'Chatbox Posts',
            'url'            => 'chatbox',
            'topic_id'        => '',
            'description'    => 'this is the rss feed for the chatbox entries', // that's 'description' not 'text' 
            'class'            => '0',
            'limit'            => '9'
        );    
        
        return $config;
    }
    
    /**
     * Compile RSS Data
     * @param $parms array    url, limit, id 
     * @return array
     */
    function data($parms='')
    {
        $sql = e107::getDb();
        
        $rss = array();
        $i=0;
                    
        if($items = $sql->select('chatbox', "*", "cb_blocked=0 ORDER BY cb_datestamp DESC LIMIT 0,".$parms['limit']))
        {

        while($row = $sql->fetch())
            {
                $tmp                        = explode(".", $row['cb_nick']);
                $rss[$i]['author']            = $tmp[1];
                $rss[$i]['author_email']    = ''; 
                $rss[$i]['link']            = "chatbox_menu/chat.php?".$row['cb_id'];
                $rss[$i]['linkid']            = $row['cb_id'];
                $rss[$i]['title']            = '';
                $rss[$i]['description']        = $row['cb_message'];
                $rss[$i]['category_name']    = '';
                $rss[$i]['category_link']    = '';
                $rss[$i]['datestamp']        = $row['cb_datestamp'];
                $rss[$i]['enc_url']            = "";
                $rss[$i]['enc_leng']        = "";
                $rss[$i]['enc_type']        = "";
                $i++;
            }

        }                
                    
        return $rss;
    }
            
        
    
}

e_related.php

Adds your plugin to the search which generates 'related' links in news items and pages of e107. See e107_plugins/news/e_related.php for an example.

e_shortcode.php

Sometimes a plugin developers wishes that his shortcode be available not only to his plugin's templates but to core templates and templates of other plugins. This is the purpose of this file. 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() eg. sc_faqs_question()

e_sitelink.php

Adds a sitelink sublink-generating function for your plugin. eg. auto-generated navigation drop-down menus for 'latest articles' etc.
See e107_plugins/news/e_sitelink.php for an example.

e_url.php

Provides a simple way to add mod-rewrite redirects to your plugin's page, without having to edit the .htaccess file. To create search-engine-friendly URLs which utilize this addon, please see the e107::url() method.

		class myplugin_url // plugin-folder + '_url' 
{
	function config() 
	{
		$config = array();
	
		$config[] = array(
			'regex'			=> '^myplugref-(.*)/?$',
			'redirect'		=> '{e_PLUGIN}myplugin/ref.php?ref=$1',
		);
				
		return $config;
	}	
}



e_user.php

Adds information about a specific user to the user's profile page. See e107_plugins/forum/e_user.php for a working example.


Thursday 17 March 2016 - 10:53:00 admin,

Social Links