Answer the question
In order to leave comments, you need to log in
How to connect a subcontroller in the controller in OpenCart 2 and pass data to it?
The OC has the following options for including a subcontroller:
$data['header'] = $this->load->controller('common/header');
$this->getChildController('checkout/simplecheckout_customer/update_session');
In both cases, the controller or one of the controller methods is loaded without passing data.
How to make it possible to pass some data to the subcontroller?
All that comes to my mind is the use of global variables.
$GLOBALS['var'] = 'test_var';
$this->load->controller('extension/module/mod/fucntion');
unset($GLOBALS['var']);
What are the alternatives?
Answer the question
In order to leave comments, you need to log in
somewhere....
in controller /product/my_module.php
public function index($arg) {
.....
$cat_id = $arg['category_id'];
The second parameter in this->load->controller is to pass an array, where the key values will become the names of the variables.
What about creating a library with the right methods and calling it in the right places?
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question