logo

Plugins

How to make plugins


Create a folder in the plugins folder of eoCMS. Please name this folder something suitable as the name will be needed to call the functions. Due to the way eoCMS works, please do not use _ in the folder name.

Now that you have created a folder, create a new file named plugin-info.php. This file contains all the information of your plugin, including who it was created by, their site and the tables it needs.
Here is an example plugin-info.php taken from the navpanel plugin
Code:

//plugin name
$plugin['name'] = 'Navigation Panel';
//plugin version. Increase number to make the system know if it is out of date
$plugin['version'] = '0.3';
//minimum version of eoCMS required to install/use the plugin
$plugin['eocms_version'] = '0.9.0';
//Layout to be included when plugin accessed
$plugin['layout'] = '';
//Layouts to be included on existing $_GET['acts'], before or after
//example array('before' => array('profile' => 'Beforeme.php', 'forum' =>'beforeme2.php'), 'after' => array('viewtopic' => 'Afterme.php', '' => 'afterme2.php'))
//files included will be located in plugins/Plugin folder/Layouts
$plugin['layout_include'] = array();
//the admin control file which will be included
$plugin['admin']['control'] = 'Admin.php';
//list of the different admin layouts, means the above layout specified can work similiarly to the index.php file of eoCMS using sa as the $_GET
$plugin['admin']['layouts'] = '';
//who created the plugin
$plugin['author']['name'] = 'confuser';
//author's site
$plugin['author']['site'] = 'http://eocms.com';
//Description to show in plugins admin area
$plugin['description']['short'] = 'Editable panel displaying links. Panel version of the Links admin area';
//Long description to show when the plugin is clicked
$plugin['description']['long'] = 'The first plugin ever built for eoCMS, like a "quick links" list, where items can be regular urls, menu links, or any other eoCMS internal url';
//create table
$plugin['tables']['create'] = array('navigation_menu' => array(
'columns' => array('id', 'name', 'link', 'item_order', 'rank', 'authid', 'window', 'height', 'width'),
'types' => array('int(225)', 'varchar(225)', 'varchar(225)', 'varchar(225)', 'varchar(225)', 'tinyint(1)', 'text', 'int(5)', 'int(5)'),
'keys' => array(
'primary' => 'id',
'auto_increment' => 'id',
'key' => 'item_order'
)
));
//List of panels included with the plugin, key is panel name to display in the drop down box in admin panel, value is the folder name
$plugin['panels'] = array('Navigation Panel' => 'navigational_panel');
//query to run if the plugin is out of date, in this case it will be run if the plugin version installed on their site is less than 0.3
$plugin['update']['alter'] = array('navigation_menu' => array(
'add_columns' => array(
'columns' => array('authid', 'window', 'height', 'width'),
'types' => array('tinyint(1)', 'text', 'int(5)', 'int(5)')
)
)
);
//queries to run when the plugin is uninstalled
$plugin['uninstall'] = array('DROP TABLE navigation_menu');


Plugin Var Notes:
Code:

$plugin['name'] = [string] //The name of your plugin!
$plugin['version'] = [version] //The version (eg 0.5.6*)
//minimum version of eoCMS required to install/use the plugin
$plugin['eocms_version'] = [version]//The minimum version of eoCMS required to install
//Layout to be included when plugin accessed
$plugin['layout'] = [path] //This is the layout file for your function, the file that contains all the display info, similar to index.php
$plugin['layout_include'] = [array] //Layouts to be included on existing $_GET['acts'], before or after. Files included will be located in plugins/Plugin folder/Layouts
$plugin['admin']['control'] = [path] //the admin control file which will be included
$plugin['admin']['layouts'] = [array] //list of the different admin layouts, means the above layout specified can work similarly to the index.php file of eoCMS using sa as the $_GET
$plugin['author']['name'] = [string] //your name
$plugin['author']['site'] = [url] //your site, free advertising
$plugin['description']['short'] = [string] //Description to show in plugins admin area
//create table
$plugin['tables']['create'] = [array]
$plugin['panels'] = [array] //List of panels included with the plugin, key is panel name to display in the drop down box in admin panel, value is the folder name
$plugin['uninstall'] = [array] //sql queries to run upon uninstall


*We recommend you use versions like this, as it helps upgrading. More info can be found here
As you can see, it states the version, if it has a admin side ($plugin[‘control’]) and the name of the layout file which the admin side is.
Please note that these queries must be compatible with SQLite as well as MySQL and vice versa.

If your plugin uses has an admin side you must create a folder named Layouts, please note this is case sensitive. Inside Layouts there must be a php file which is the Admin CP for this plugin. Examples can be found in the navbar plugin. Also if your plugin has a user side or guest side then you must define the $plugin[‘layout’] to the name of the Layout file within the Layout folder which will be viewed first when your plugin page visited ie: yourdomain.com/index.php?act=plugin&id=whatever the CMS set the id of your plugin to.

All plugin functions must go inside a folder named functions inside your plugin folder. Here each function will have its own file which within it has stated the function, eg addlink.php
Code:

function addlink($test) {
//do whatever you wish here
}

Now you may or may not have noticed but the function name must be the same as the file name, this is case sensitive.

To use a plugin function you use the plugin() function like so:
plugin('navpanel’, ‘addlink', “this is the argument for $testâ€);
The first argument is the folder that the plugin is called, in this case it is navpanel, this tells eoCMS that you wish to call a plugin function from the navpanel functions folder which contains the function addlink which is the name of the file and function we want to call.

If you wish to run any code before the tables are created and the plugin data is inserted into the database, please use this if() statement, anything inside will processed before plugin install
Code:

if(isset($plugin_install)) {
//code to run during installation PRE table creation
}

If you wish to run any queries AFTER table creation use the following variable

Code:
$plugin['tables']['extra'] = array("PURE SQL QUERY HERE", "ANOTHER QUERY HERE");


Ratings
Rating: 4.75/5 (8 Votes)

Comments
manicgames on 9th April, 2009, 01:53:03 AM
Nice tutorial, makes things easier! Tongue
Arwym on 10th April, 2009, 01:44:45 AM
Yeah.  It explains very well.  I've yet to try, but I'm pretty sure it'll make things easier.
TGPEG on 11th April, 2009, 10:22:09 PM
This will help a fair few people. Tick
Demonic on 18th April, 2009, 02:36:30 AM
Pretty good tutorial.... I think I might try to make a plugin.
smooch1502 on 13th May, 2009, 12:33:10 PM
i will try to however do we have to make an install script
confuser on 13th May, 2009, 10:55:21 PM
Please post questions via the forum, as the devs and I rarely look on these pages
on 14th January, 2016, 06:44:01 PM
hijri date
This article is about the lunar Hijri calendar. For the solar calendar whose first year is fixed to the Hijra, see Solar Hijri calendar.
The Islamic calendar, Muslim calendar or Hijri calendar (AH)[1][2] is a lunar calendar consisting of 12 months in a year of 354 days.
It is used to date events in many Muslim countries (concurrently with the Gregorian calendar), and used by Muslims everywhere to determine the proper days on which to observe the annual fasting, to attend Hajj, and to celebrate other Islamic holidays and festivals.
The first year was the Islamic year beginning in AD 622 during which the emigration of Muhammad from Mecca to Medina, known as the Hijra, occurred. Each numbered year is designated either "H" for Hijra or "AH" for the Latin Anno Hegirae ("in the year of the Hijra");[3] hence, Muslims typically call their calendar the Hijri calendar.
on 14th January, 2016, 06:45:31 PM
hijri date
This article is about the lunar Hijri calendar. For the solar calendar whose first year is fixed to the Hijra, see Solar Hijri calendar.
The Islamic calendar, Muslim calendar or Hijri calendar (AH)[1][2] is a lunar calendar consisting of 12 months in a year of 354 days.
It is used to date events in many Muslim countries (concurrently with the Gregorian calendar), and used by Muslims everywhere to determine the proper days on which to observe the annual fasting, to attend Hajj, and to celebrate other Islamic holidays and festivals.
The first year was the Islamic year beginning in AD 622 during which the emigration of Muhammad from Mecca to Medina, known as the Hijra, occurred. Each numbered year is designated either "H" for Hijra or "AH" for the Latin Anno Hegirae ("in the year of the Hijra");[3] hence, Muslims typically call their calendar the Hijri calendar.



0.03 seconds Queries: 10