There I dont think is any built in support - but we currently have a crude way to do this in the control-panel. Our code needs a review and tidy up (i.e. should use call_user_func_array etc) but I will copy it here for you.
We use extra querystring parameters to determine which controller and method to call.
i.e. The following URL will call our Customer controllers index method, we have already require_onced this controller in our module directory..
http://localhost/system/index.php/index.php?D=cp&C=addons_modules&M=show_module_cp&module=simplicart&method=index&C2=customer&M2=index
Add this method to you mcp.modulename.php file
function __call($method, $args)
{
$controller = $this->EE->input->get_post('C2');
$method = $this->EE->input->get_post('M2');
$args = array();
if ($this->EE->input->get_post('A0') !== FALSE)
{
$args[0] = $this->EE->input->get_post('A0');
}
if ($this->EE->input->get_post('A1') !== FALSE)
{
$args[1] = $this->EE->input->get_post('A1');
}
if ($this->EE->input->get_post('A2') !== FALSE)
{
$args[2] = $this->EE->input->get_post('A2');
}
if ($controller)
{
$controller_name = ucwords($controller).'_controller';
$controller = new $controller_name();
}
else
{
return Dashboard_controller::index();
}
return $controller->$method((isset($args[0]) ? $args[0] : NULL), (isset($args[1]) ? $args[1] : NULL), (isset($args[2]) ? $args[2] : NULL));
}Something similar would work on the front-end.
I understand we can create libraries in 3rd party modules. But what about controllers? Can we?
Not a lot to go by, but In many ways your control panel mcp file is a controller. We do a handful of things to make that experience more authentic, like modifying the form_validation callbacks to go to the active mcp file.
The frontend is a different beast, of course. Could you tell us what you’re trying to achieve?
In my module (in my signature) we are writing new modules within this module. So, let’s say there are 3 modules A, B, C ..now we can have their respective folders for views and models, but for all these modules, there can be just one “mcp” controller..so the code becomes huge in that one file. For the first module itself the code is already 800 lines, so if we keep on adding modules to EESuite, it will be a nightmere to maintain this one controller file (mcp).
So I am looking for a way to keep all submodules related functionality in their respective folders…
Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.