Welcome Guest, Not a member yet? Register   Sign In
Codeigniter 3 HMVC default_controller
#1

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
Reply
#2

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

(This post was last modified: 01-09-2015, 03:20 AM by sintakonte.)

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';
Reply
#4

(This post was last modified: 01-09-2015, 03:36 AM by sintakonte.)

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/codeig...s=declined

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

(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.
Reply
#6
Lightbulb 

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
Reply
#7

(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/codeig...s=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Ā 
Reply




Theme © iAndrew 2016 - Forum software by © MyBB