简体   繁体   中英

How to get Modules Name in HMVC Codeigniter

I have a couple of controllers in two modules with same name and both works fine. also i have a function for checking access permission, it uses $this->router->fetch_class() .
problem is $this->router->fetch_class() returns controller name and it's the same. but i need Modules name too.

Structure of the Modules

/modules
    /product
        /controllers
            /product.php
            /options.php [1]
        /models
        /views
    /inventory
        /controllers
            /inventory.php
            /options.php [2]
        /models
        /views

and urls are:

[1]: ../product/options/function_name
[2]: ../inventory/options/function_name

so is there any way to check access permission without changing controllers name?

Like @sintakonte said, you can use the uri library .

Using segment you can get each part of the url.

Module names are always the first part after your domain.

$module_name = $this->uri->segment(1);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM