[eluser]wiredesignz[/eluser]
This is an example of a base controller using the _remap() method to load modules HMVC style.
Code:
<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
class Base extends Controller
{
function Base()
{
parent::Controller();
$this->load->library('modules');
}
function _remap()
{
$path = $this->uri->segment(2).'/';
$module = $path.$this->uri->segment(3);
$action = $this->uri->segment(4);
$this->modules->load($module, $action);
}
}
Code:
http://127.0.0.1/base/admin/products/edit
The admin/products module:
Code:
<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
class Products extends Modules
{
function Products($action = NULL)
{
parent::Modules();
$this->load->model('products_model', 'products');
if ($action) $this->$action();
}
function add()
{
echo 'admin/products/add';
}
function edit()
{
echo 'admin/products/edit';
}
}