对于特色模块中显示的每个产品,我都有一个弹出窗口,在该弹出窗口中,我想显示与产品页面外观相似的产品的所有图像,即 1 张大图像,下方有其他图像的缩略图,单击时会更新大图像。
为此,我将一些代码从控制器 product.php 复制到控制器模块 features.php 但这似乎不起作用。这是我的代码:
控制器/扩展/模块/特色.php
if ($product_info) {
if ($product_info['image']) {
$image = $this->model_tool_image->resize($product_info['image'], $setting['width'], $setting['height']);
} else {
$image = $this->model_tool_image->resize('placeholder.png', $setting['width'], $setting['height']);
}
if ($product_info['image']) {
$data['popup'] = $this->model_tool_image->resize($product_info['image'], $this->config->get('theme_' . $this->config->get('config_theme') . '_image_popup_width'), $this->config->get('theme_' . $this->config->get('config_theme') . '_image_popup_height'));
} else {
$data['popup'] = '';
}
$data['images'] = array();
$results = $this->model_catalog_product->getProductImages($this->model_catalog_product->getProduct($product_id));
foreach ($results as $result) {
$data['images'][] = array(
'popup' => $this->model_tool_image->resize($result['image'], $this->config->get('theme_' . $this->config->get('config_theme') . '_image_popup_width'), $this->config->get('theme_' . $this->config->get('config_theme') . '_image_popup_height')),
'thumb' => $this->model_tool_image->resize($result['image'], $this->config->get('theme_' . $this->config->get('config_theme') . '_image_additional_width'), $this->config->get('theme_' . $this->config->get('config_theme') . '_image_additional_height'))
);
}
// some other code in between
$data['products'][] = array(
'product_id' => $product_info['product_id'],
'thumb' => $image,
'popup' => $image,
'name' => $product_info['name'],
'description' => utf8_substr(strip_tags(html_entity_decode($product_info['description'], ENT_QUOTES, 'UTF-8')), 0, $this->config->get('theme_' . $this->config->get('config_theme') . '_product_description_length')) . '..',
'price' => $price,
'special' => $special,
'tax' => $tax,
'rating' => $rating,
'href' => $this->url->link('product/product', 'product_id=' . $product_info['product_id'])
);
对于视图/主题/扩展/模块/特色.twig
{% if thumb or images %}
<ul class="thumbnails">
{% if thumb %}
<li><a class="thumbnail" href="{{ popup }}" title="{{ heading_title }}"><img src="{{ thumb }}" title="{{ heading_title }}" alt="{{ heading_title }}" /></a></li>
{% endif %}
{% if images %}
{% for image in images %}
<li class="image-additional"><a class="thumbnail" href="{{ image.popup }}" title="{{ heading_title }}"> <img src="{{ image.thumb }}" title="{{ heading_title }}" alt="{{ heading_title }}" /></a></li>
{% endfor %}
{% endif %}
</ul>
{% endif %}