除了拇指图像我想在类别页面上显示每个产品的第一个附加图像,有谁知道如何做到这一点?
我知道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测试了这个