CodeIgniter Forums
Codeigniter 3 HMVC default_controller - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Development (https://forum.codeigniter.com/forumdisplay.php?fid=6)
+--- Forum: CodeIgniter 3.x (https://forum.codeigniter.com/forumdisplay.php?fid=17)
+--- Thread: Codeigniter 3 HMVC default_controller (/showthread.php?tid=712)



Codeigniter 3 HMVC default_controller - dts - 01-08-2015

Hi,

How set $route["default_controller"] with HMVC (wiredesignz) in Codeigniter 3 ?

I have this code in application/config/routes.php :
Code:
$route['default_controller'] = 'home';
Result: Error 404 (from Codeigniter)

The same code is working in Codeigniter 2.x.

I add this in modules/home/config/routes.php
PHP Code:
<?php
$route
['home'] = 'home/sayhello'
but this result is the same: error 404 (from codeigniter)

Please


RE: Codeigniter 3 HMVC default_controller - Avenirer - 01-09-2015

As I remember, wiredesignz HMVC doesn't work with CI3. I may be wrong...


RE: Codeigniter 3 HMVC default_controller - sintakonte - 01-09-2015

if you can call home/sayhello directly in your browser with the desired result

you can create a default controller in CIs controllers folder

something like


PHP Code:
class DefaultController extends CI_Controller
{

    public function 
landingpage()
    {
        echo 
modules::run("home/sayhello");
    }


and in your routes php

Code:
$route['default_controller'] = 'DefaultController/landingpage';



RE: Codeigniter 3 HMVC default_controller - sintakonte - 01-09-2015

In order to get HMVC running for CI you need to update some files in the third_party/mx/ folder;
there is a version of the loader class for CI 3.0 on bitbucket

https://bitbucket.org/wiredesignz/codeigniter-modular-extensions-hmvc/pull-requests?displaystatus=declined

And you need to change the Router.php in order to get the possibility to load modules from subdirectories and so on


RE: Codeigniter 3 HMVC default_controller - dts - 01-09-2015

(01-09-2015, 03:19 AM)sintakonte Wrote: if you can call home/sayhello directly in your browser with the desired result

you can create a default controller in CIs controllers folder

something like



PHP Code:
class DefaultController extends CI_Controller
{

 public function 
landingpage()
 {
 echo 
modules::run("home/sayhello");
 }


and in your routes php


Code:
$route['default_controller'] = 'DefaultController/landingpage';

Shy Thankyou very much sintakonte, works but with extends MX_Controller. For this time is the one way. Thanks again.


RE: Codeigniter 3 HMVC default_controller - matup - 03-12-2015

I think it's also possible to add the following rule at the end of all the rules:

PHP Code:
$route['(.*)'] = "directory/to/default/controller"

This should do the trick, but it is also necessary to implement 404 handle in the default controller if applies.

Hope it works for you!
Matup


RE: Codeigniter 3 HMVC default_controller - projack89 - 04-15-2015

(01-09-2015, 03:35 AM)sintakonte Wrote: In order to get HMVC running for CI you need to update some files in the third_party/mx/ folder;
there is a version of the loader class for CI 3.0 on bitbucket

https://bitbucket.org/wiredesignz/codeigniter-modular-extensions-hmvc/pull-requests?displaystatus=declined

And you need to change the Router.php in order to get the possibility to load modules from subdirectories and so on

I have update some files like your comments and HMVC for CI 3 works fineĀ