First of all download CI and make a fresh instalation. No one likes /index.php/ in the urls, so we add for our project .htaccess file with these lines:
RewriteEngine on RewriteCond $1 !^(index\.php|robots\.txt|assets) RewriteRule ^(.*)$ /index.php/$1 [L]
and remove "index.php" from line #54 in our ./application/config/config.php file to have this instruction:
$config['index_page'] = '';
--------------------------------------------------------------------------------
Now we are going to make our CI application modular. Download Modular Extentions - HMVC and put it's content (just "core" and "third_party" folders) to the corresponding CodeIgniters folders.
In the next step create ./application/modules/ folder. Then create ./application/modules/welcome/ folder and create in it ./applications/modules/welcome/controllers/ and ./applications/modules/welcome/views/ folders.
Then move ./application/controllers/welcome.php file to ./application/modules/welcome/controllers/welcome.php. And ./application/views/welcome_message.php file to ./application/modules/welcome/views/welcome_message.php (ughh, sorry for this
Go to the ./application/config/config.php file and add this line to say where our modules are located:
$config['modules_locations'] = array(APPPATH.'modules/' => '../modules/');
Now just change line#28 in welcome.php into this, so our contoller extends MX_Controller and not CI_Controller:
class Welcome extends MX_Controller {
After this, if we see in the browser favorite "Welcome to CodeIgniter!", then everythigs is OK and our CI is modular.
--------------------------------------------------------------------------------
Now go to the grocery_CRUD and download it. Use examples_database.sql for creating your test db. Then put ./assets/ folder along with ./application/ and ./system/ CI-folders.
Create new ./application/modules/grocery_crud/ folder and put into it content of grocery_CRUD ./application/ folder to have structure like this:
./application/
...
/modules/
/grocery_crud/
/config/
/controllers/
/libraries/
/models/
/views/
index.html
/welcome/
...
Since we have HMVC our controllers have to extend MX_Controller. Go to the ./application/modules/grocery_crud/controllers/examples.php file and change line#3 into this:
class Examples extends MX_Controller {
I encoutered the problem: MX_Loader doesn't want to load library if it's name capitilize. So change and the line#11 into:
$this->load->library('grocery_crud');
and add line#12:
$this->load->helper('url');
to load the url_helper for our links.Then go to the ./application/modules/grocery_crud/views/example.php file and change lines#31-36 into these:
<a href='<?php echo site_url('grocery_crud/examples/customers_management')?>'>Customers</a> |
<a href='<?php echo site_url('grocery_crud/examples/orders_management')?>'>Orders</a> |
<a href='<?php echo site_url('grocery_crud/examples/products_management')?>'>Products</a> |
<a href='<?php echo site_url('grocery_crud/examples/offices_management')?>'>Offices</a> |
<a href='<?php echo site_url('grocery_crud/examples/employees_management')?>'>Employees</a> |
<a href='<?php echo site_url('grocery_crud/examples/film_management')?>'>Films</a>
And the last thing: add ./application/modules/grocery_crud/config/routes.php file with this content:
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
$route['grocery_crud'] = 'examples';
/* End of file routes.php */
/* Location: ./application/modules/grocery_crud/config/routes.php */
in order to have routing to the examples controller, when we access your_project.com/grocery/If you can browse your_project.com/grocery_crud and see the index of grocery everything is fine.
Result in .zip archive can be found in ci_hmvc_grocery_crud.
Additional documentation you can find in wiki & docs of CI, Modular Extentions - HMVC and grocery_CRUD.












