php - Getting NULL in template - OpenCart 2.0 -
i trying render product_list.tpl
file in home.tpl
it's giving me null
controller file:
/controller/product/product_list.php
code:
class controllerproductproductlist extends controller { public function index() { $this->load->model('catalog/category'); $this->load->model('catalog/product'); $this->load->model('tool/image'); $filter_data = array( 'filter_tag' => 'featured', 'limit' => 9 ); $data['results'] = $this->model_catalog_product->getproducts($filter_data); if (file_exists(dir_template . $this->config->get('config_template') . '/template/common/productlist.tpl')) { $this->response->setoutput($this->load->view($this->config->get('config_template') . '/template/common/productlist.tpl', $data)); } else { $this->response->setoutput($this->load->view('default/template/common/productlist.tpl', $data)); } } }
template render
/template/product/productlist.tpl
code:
<?php var_dump($results); ?> <h2>product here</h2>
then adding line in home.php
controller
$data['special_mod'] = $this->load->controller('product/product_list');
and printing $special_mod
in common/home.tpl
file
the problem in /controller/product/product_list.php
the method $this->response->setoutput
doesn't return value send user different page while wanted output productlist.tpl
string had replace code
if (file_exists(dir_template . $this->config->get('config_template') . '/template/common/productlist.tpl')) { $this->response->setoutput($this->load->view($this->config->get('config_template') . '/template/common/productlist.tpl', $data)); } else { $this->response->setoutput($this->load->view('default/template/common/productlist.tpl', $data)); }
with
if (file_exists(dir_template . $this->config->get('config_template') . '/template/common/productlist.tpl')) { return $this->load->view($this->config->get('config_template') . '/template/common/productlist.tpl', $data); } else { return $this->load->view('default/template/common/productlist.tpl', $data); }
Comments
Post a Comment