At the moment, in Opencart 2.0, the controller uses a local array variable like
$data instead of a class property such as
$this->data to fill in all relevant variables for the view:
Also, Opencart 2.0 now uses something like this for generating the view:
Code: Select all
$this->response->setOutput($this->load->view($this->config->get('config_template') . '/template/product/category.tpl', $data));
Both of this makes it a lot harder to extend controller classes and override a method for 3rd party modifications from addons. Can we re-introduce the
render method and use that one, e.g. something like this:
Code: Select all
$this->response->setOutput($this->render($this->config->get('config_template') . '/template/product/category.tpl', $data))
This would give an extended controller class the chance to override the
render method so that it can add or modify its own variables for the view!
I suggest to add a method named
render into the
system/engine/controller.php, as follows:
Code: Select all
public function render( $template, $data ) {
return $this->load->view( $template, $data );
}
See also my entry on
github.