How to route URIs to application/controllers & sti

2019-07-23 05:36发布

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.

enter image description here

@ /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)?

0条回答
登录 后发表回答