[英]Opencart 2.1.3 | Display one additional image along with thumb on category.tpl
除了拇指图像之外,我还想在类别页面上显示每个产品的第一个附加图像,有人知道如何执行此操作吗?
我知道需要修改Controller中的category.php以加载其他图像,以便可以将其调用到View category.tpl上,但是我的编码知识还不够好。 我曾尝试使用产品中的代码,但我也不完全确定那里另外的图像是如何被调用的。
任何帮助,将不胜感激!
尽管没有OpenCart 2.1.3版本,但是这是您可以在类别页面中显示第一个其他图像的方法。
在category.php
查找 :
$data['products'][] = array(
'product_id' => $result['product_id'],
'thumb' => $image,
用。。。来代替:
$image_results = $this->model_catalog_product->getProductImages($result['product_id']);
if ($image_results) {
$image2 = $this->model_tool_image->resize($image_results[0]['image'], $this->config->get($this->config->get('config_theme') . '_image_product_width'), $this->config->get($this->config->get('config_theme') . '_image_product_height'));
} else {
$image2 = false;
}
$data['products'][] = array(
'product_id' => $result['product_id'],
'thumb' => $image,
'thumb2' => $image2,
然后在category.tpl
,在foreach
使用它:
<?php if($product['thumb2']){ ?><img src="<?php echo $product['thumb2']; ?>"><?php } ?>
我使用OpenCart 2.3.0.2对此进行了测试
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.