我大约有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';
}
}发布于 2015-04-04 16:20:42
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));
} 你想要这个还是别的什么?
https://stackoverflow.com/questions/29434957
复制相似问题