我有大约20个左右的产品需要加载特定的产品模板,而其他所有产品都加载了默认值。这是我到目前为止的代码。我无法弄清楚如何合并多个产品ID。任何帮助将不胜感激。
if ($this->request->get['product_id'] == 200000864) {
if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/product/customproduct.tpl')) {
$this->template = $this->config->get('config_template') . '/template/product/customproduct.tpl';
} else {
$this->template = '/template/product/customproduct.tpl';
}
} else {
if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/product/product.tpl')) {
$this->template = $this->config->get('config_template') . '/template/product/product.tpl';
} else {
$this->template = '/template/product/customproduct.tpl';
}
}
答案 0 :(得分:0)
Opencart 2.0
这
if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/product/product.tpl')) {
$this->response->setOutput($this->load->view($this->config->get('config_template') . '/template/product/product.tpl', $data));
} else {
$this->response->setOutput($this->load->view('default/template/product/product.tpl', $data));
}
要
switch ($this->request->get['product_id']) {
case 1:
$this->response->setOutput($this->load->view('default/template/product/product1.tpl', $data));
break;
case 2:
$this->response->setOutput($this->load->view('default/template/product/product2.tpl', $data));
break;
//...
//...
//...
case 200000864:
$this->response->setOutput($this->load->view('default/template/product/product200000864.tpl', $data));
break;
default:
$this->response->setOutput($this->load->view($this->config->get('config_template') . '/template/product/product.tpl', $data));
}
你想要这个或其他什么