First of all download CI and make a fresh instalation. No one likes /index.php/ in the urls, so we add for our project [b].htaccess[/b] 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 [b]./application/config/config.php[/b] 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/[b]modules[/b]/ folder. Then create ./application/modules/[b]welcome[/b]/ folder and create in it ./applications/modules/welcome/[b]controllers[/b]/ and ./applications/modules/welcome/[b]views[/b]/ folders.
Then move ./application/controllers/welcome.php file to [b]./application/modules/welcome/controllers/welcome.php[/b]. And ./application/views/welcome_message.php file to [b]./application/modules/welcome/views/welcome_message.php[/b] (ughh, sorry for this ).
Go to the [b]./application/config/config.php[/b] 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 [b]welcome.php[/b] 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 ./[b]assets[/b]/ folder along with ./application/ and ./system/ CI-folders.
Create new [b]./application/modules/grocery_crud/[/b] folder and put into it content of grocery_CRUD ./application/ folder to have structure like this:
./application/
[indent=1]...[/indent]
[indent=1]/modules/[/indent]
[indent=2]/grocery_crud/[/indent]
[indent=3]/config/[/indent]
[indent=3]/controllers/[/indent]
[indent=3]/libraries/[/indent]
[indent=3]/models/[/indent]
[indent=3]/views/[/indent]
[indent=3]index.html[/indent]
[indent=2]/welcome/[/indent]
[indent=3]...[/indent]
Since we have HMVC our controllers have to extend [b]MX_Controller[/b]. 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 [b]./application/modules/grocery_crud/views/example.php[/b] 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 [b]./application/modules/grocery_crud/config/routes.php[/b] 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 [b]your_project.com/grocery_crud[/b] and see the index of grocery everything is fine.
Result in [b].zip archive[/b] can be found in ci_hmvc_grocery_crud.
Additional documentation you can find in wiki & docs of CI, Modular Extentions - HMVC and grocery_CRUD.