Reputation: 377
I just started learning OpenCart, currently using version 2.3.0.2 .
I created a module, everything works fine on the backend.
On the frontend however, when I return the template from the controller it shows up blank.
But if I add a die();
in the template it loads the template.
Controller code:
<?php
class ControllerExtensionModuleHelloworld extends Controller {
public function index() {
$this->load->language('extension/module/helloworld');
$data['heading_title'] = $this->language->get('heading_title');
$data['helloworld_value'] = html_entity_decode($this->config->get('helloworld_text_field'));
if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/extension/module/helloworld.tpl')) {
// print_r(__LINE__);
return $this->load->view($this->config->get('config_template') . '/template/extension/module/helloworld.tpl', $data);
} else {
// print_r(__LINE__);
return $this->load->view('extension/module/helloworld.tpl');
}
}
}
Template code:
<div class="panel panel-default">
<div class="panel-heading"> <?php echo $heading_title; ?> </div>
<div class="panel-content" style="text-align: center;"> <?php echo $helloworld_value; ?> </div>
<div style="height:100px;width:100px;background-color:blue;"></div>
</div>
Upvotes: 1
Views: 627
Reputation: 377
Fixed it by changing:
return $this->load->view('extension/module/helloworld.tpl', $data);
To:
$this->response->setOutput($this->load->view('extension/module/helloworld.tpl', $data));
Upvotes: 1