Welcome Guest, Not a member yet? Register   Sign In
Managing HMVC Modules in a CMS system, Tips & Advice ?
#1

[eluser]opel[/eluser]
I have managed to use the HMVC and Template libraries to make self contained modules that can be added to projects, almost drag and drop.

However, I wondered if anyone was doing something similar and how they managed modules so that they appear in the admin navigation, public site etc.

Do you use a DB table, config file (like Django does) etc.

Any suggestions or advice is appreciated.
#2

[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');
    }
}
?&gt;

I know its a vague explanation, but that's about as simple as I can make it without going too in-depth.
#3

[eluser]opel[/eluser]
Whoa that seems like a cool extension, gave me some ideas on how I could tackle this. Let me know if you post the code or a tutorial anywhere.

cheers
#4

[eluser]simshaun[/eluser]
Maybe when I get time I'll write up an article/tutorial on it.
I wrote it all for a CMS I'm building at work, and I'm still in rigorous development on that.
Therefore, I don't have a lot of time at the moment.

The plugin system is sort of like WordPress's, if you want to do some research on how theirs works.




Theme © iAndrew 2016 - Forum software by © MyBB