How to route URIs to application/controllers & still use Module::run in CI3 with HMVC

◇◆丶佛笑我妖孽 提交于 2019-12-24 05:48:38

问题


I only use the modules for partial views, they are never routed to directly. Instead I have main controllers inside application/controllers and views inside application/views/ which execute Modules::run($moduleName, $params); This invokes the module and renders fine, when reached.

The problem is none of my routes are calling their application/controller/ methods. Meaning my routing has stopped working entirely and only the homepage defined by my route['default_controller'] works. Because my main template file in application/views calls Modules::run($moduleName, $params) successfully, I can verify the modules and HMVC is working fine independently.

I recently upgrade from CodeIgniter 2 to 3 as well as the Module Extensions - HMVC package from WireDesignz. See the picture for directory struction and relevant files.

@ /application/config/routes.php:

$route['default_controller'] = "dashboardcontroller/index";
$route['playlist(|.+?)'] = "dashboardcontroller/custommethod";

@ /application/controllers/Dashboardcontroller.php (note die() statements):

<?php if (!defined('BASEPATH')) exit('No direct script access allowed');

class dashboardcontroller extends MX_Controller {

    private $data = array("pagi"=>array(), "me"=>array(), 'errors'=>null);

    function __construct() {
        parent::__construct();
    }
    function index() {
        die("THIS IS THE ONLY THING EVER HIT");
    }   
    function custommethod($moduleName, $params) {
         die("THIS IS NEVER HIT");      
    }
}

When I change Dashboardcontroller.php to extend CI_Controller I get a cascade of errors starting with MX/Base.php re-declaring the CI class.

How can I route URIs to application/controllers and still use Module::run($moduleName, $params)?

来源:https://stackoverflow.com/questions/36351247/how-to-route-uris-to-application-controllers-still-use-modulerun-in-ci3-with

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!