[eluser]simshaun[/eluser]
I've created my own Plugin system that does this.
All plugins are placed in a folder.
Each plugin has a multi-line comment with meta info such as Plugin Name, Version, Author, Description, etc..
I've got a page in my admin for Plugin administration.
Upon opening that page, the script:
1. Detects all plugins (files) inside a folder.
2. Opens the plugin and parses the meta comment.
3. Checks for that plugin in the database.
4. If it doesnt exist, a row is added with the plugin information and status (deactivated by default)
5. If it does exist, do a comparison on the meta info. If different from the database, update the database.
Next, I've built an extension to the Hooks system that lets me create my own hooks and call them anywhere in my controllers.
Plugins can call a function to register themselves into any Hook.
I've got another library called PluginLoader, which is auto-loaded by CI.
It queries activated plugins from the database, and includes each one.
At this point, all plugins will have registered themselves into whatever hooks.
In order to utilize a hook (and any plugins in the hook's array)..
Code:
<?php
class Blog extends Controller {
function Blog()
{
parent::Controller();
$this->load->library('MyHooks');
}
function index()
{
$header['menu_items'] = array();
$header['menu_items'] = $this->MyHooks->filter('hookMenuItems', $header['menu_items']);
// Plugins registered to hookMenuItems will take the $header['menu_items'] array,
// and append elements to it
$this->load->view('header', $header); // header loops through the $header['menu_items'] array, adding each element to a <ul>
$this->load->view('dashboard');
$this->load->view('footer');
}
}
?>
I know its a vague explanation, but that's about as simple as I can make it without going too in-depth.