Welcome Guest, Not a member yet? Register   Sign In
CI3 and HMVC: fetch_module() issue

(This post was last modified: 04-01-2020, 03:40 AM by Zeff.)

Hi all,

In a CI HMVC project, I created a module for managing navigation and breadcrumbs of the site.
In each module (take the example 'Start' module), I try to load the 'custom' menu and breadcrumb views (partials) by placing the following code at the end of the constructor:

PHP Code:
Class Start extends MX_Controller

    // Some class properties...
    // ...
// $data contains all vars used in template and view files
    $data = [];
public function __construct()

        // Some other code
        // ...
// Navigation & breadcrumb view partials
        $location = array(
                            'active_method' => $this->router->fetch_method(), 
                            'active_class' => $this->router->fetch_class(), 
                            'active_module' => 'start'

        $this->data['topnavigation'] = modules::run('navigation/topnavigation'$location);
        $this->data['breadcrumb'] = modules::run('navigation/breadcrumb'$location);

public function index(){
        die(echo $this->router->fetch_module()); // expecting 'start' BUT returning 'navigation'...

This works perfect, presenting a nice navigation and breadcrumb html snippet in any page of the (parent) 'Start' module.
BUT when I open the page 'http://mysite.io/start/index/' (containing just the simple code in the above code example), I see 'navigation' instead of 'start'!?!?

Can anyone help with this issue?
In the /application/third_party/MX/Router.php, fetch_module is coded as:

[Image: fetch_module.png]

Theme © iAndrew 2016 - Forum software by © MyBB