我正在尝试渲染product_list.tpl
文件,home.tpl
但它给了我NULL
控制器文件:
/controller/product/product_list.php
代码:
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/product/productlist.tpl
代码:
<?php var_dump($results); ?>
<h2>Product are here</h2>
然后在home.php
控制器中添加这一行
$data['special_mod'] = $this->load->controller('product/product_list');
$special_mod
并在common/home.tpl
文件中打印