Post by JNeuhoff » Sun Dec 29, 2013 2:58 am

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:

Code: Select all

$data['whatever'] = ....;
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.

Export/Import Tool * SpamBot Buster * Unused Images Manager * Instant Option Price Calculator * Number Option * Google Tag Manager * Survey Plus * OpenTwig


User avatar
Guru Member

Posts

Joined
Wed Dec 05, 2007 3:38 am


Post by billynoah » Tue Aug 11, 2015 5:32 am

Is this the reason I can no longer access methods like

Code: Select all

 $this->request->get()
and

Code: Select all

$this->config->get()
from the template?

Image


Active Member

Posts

Joined
Tue Jan 15, 2013 12:46 pm
Who is online

Users browsing this forum: No registered users and 2 guests