在OpenCart 2上的商店中有几种类型的商品,并且需要彼此的结构和设计。如何实现?访问的选项与创建控制器和模板输出,但不工作.
发布于 2016-11-20 15:51:47
解决了。有人能帮上忙吗。
在文件\catalog\controller\product\category.php中
替换代码:
if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/product/category.tpl')) {
$this->response->setOutput($this->load->view($this->config->get('config_template') . '/template/product/category.tpl', $data));
} else {
$this->response->setOutput($this->load->view('default/template/product/category.tpl', $data));
}对此:
$template = 'category.tpl';
if ($category_id == 72) { $template = 'category-72.tpl'; }
if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/product/'.$template)) {
$this->response->setOutput($this->load->view($this->config->get('config_template') . '/template/product/'.$template, $data));
} else {
$this->response->setOutput($this->load->view('default/template/product/'.$template, $data));
}而不是72放置您的类别id。
在这里创建我们的类别的模板:
\catalog\view\theme\NAME_THEME\template\product\category-72.tpl
然后转到Admin -> Modules -> 修饰符并更新缓存。好了。
发布于 2016-11-18 13:20:23
在Opencart 2中,body有与正在查看的页面相关的class,例如,如果您属于某个类别,body class应该是:
<body class="product-category-20">你可以这样使用它:
body.product-category-20 {
background-color: red;
}另一类别;
body.product-category-21 {
background-color: green;
}对于为每个类别分配不同的模块,您可以添加一个新的布局,然后在编辑或创建新类别时从“设计”选项卡中选择此布局。
https://stackoverflow.com/questions/40673910
复制相似问题