Question

I have created header_top.tpl in the catalouge folder (down in the theme "common" folder) and then a controller in the controller folder. But I do not know how should I render a template with a controller (and send data from controller to the template to be further parsed by the template).

I know $this->render() does render the template but what happens before to it is vague to me.

Was it helpful?

Solution

There should be a condition similar to the below the code in your controller file. Replace with your template file in that section as given below:

 if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/common/header_top.tpl')) {
      $this->template = $this->config->get('config_template') . '/template/common/header_top.tpl';
 } else {
      $this->template = 'default/template/common/header_top.tpl';
 }

Values set as $this->data['sitename'] = 'stackoverflow'; in controller file can be used in template file like echo $sitename;

Have a nice day !!

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top