Setting a module as homepage in codeigniter HMVC

2.3k Views Asked by At

Today I started using Codeigniter+the modular extension from wiredesignz(hmvc) and I have a lot of unanswered questions but for the moment I will stick only to 1 .I understood how the modules work and I want to create a test website where I have 3 modules ( home,about and blog ) .

My folder structure :

Home 
|-controllers
|-models
|-views
About
|-controllers
|-models
|-views
Blog
|-controllers
|-models
|-views

Now the question : How can I make the home module to be seen as homepage/main page ? I tried with config

$config['base_url'] = 'modules/home'; it didn't work 

I tried some tweaks from the main index file but unfortunately it bricked my code. I tried with htaccess but nothing . Thank you .

4

There are 4 best solutions below

0
On

Each module may contain a config/routes.php file where routing and a default controller can be defined for that module using:

$route['module_name'] = 'controller_name';

Taken from wiredesignz.

0
On

Kiran above was bit close. I tried to do so on live environment but failed. Apparently, this would work only if your default module and default controller are same (that is, home). Otherwise, you'll have to specify the module name as well as the controller name. In my case, I specified module name and controller name in default controller and it picked up!
$route['default_controller'] = 'admin/home';
In your case, it would be:
$route['default_controller'] = 'home/controller_name';

0
On

just go to your application\config\routes.php and change your default controller to the module and controller you want:

$route['default_controller'] = 'module/controller_name';

0
On

It might help to you, if still you are waiting for answer, Change your default controller to "home" controller. In config/routes.php

$route['default_controller'] = 'home';//home is the controller name of home module.