我已经设置了opencart3商店。如何在“类别”页面中显示带有图像的子类别?
答案 0 :(得分:0)
将下面的代码复制到install.xml文件中,将其压缩为images_for_refine_search.ocmod.zip安装,不要忘记刷新修改并清除管理控制台中的缓存...
<?xml version="1.0" encoding="utf-8"?>
<modification>
<name>Images for Reafine Search</name>
<code>Images for Reafine Search</code>
<version>1.0</version>
<author>K.B.</author>
<link><![CDATA[https://www.opencart.com/index.php?route=marketplace/extension&filter_member=SmartTech]]></link>
<file path="catalog/controller/product/category.php">
<operation error="skip">
<search>
<![CDATA[$data['categories'][] = array(]]>
</search>
<add position="before">
<![CDATA[
/*images for refine search*/
if ($result['image']) {
$image['thumb'] = $this->model_tool_image->resize($result['image'], $this->config->get('theme_' . $this->config->get('config_theme') . '_image_category_width'), $this->config->get('theme_' . $this->config->get('config_theme') . '_image_category_height'));
} else {
$image['thumb'] = $this->model_tool_image->resize('placeholder.png', $this->config->get('theme_' . $this->config->get('config_theme') . '_image_product_width'), $this->config->get('theme_' . $this->config->get('config_theme') . '_image_product_height'));
}
/*images for refine search*/
]]>
</add>
</operation>
<operation error="skip">
<search>
<![CDATA['href' => $this->url->link('product/category', 'path=' . $this->request->get['path'] . '_' . $result['category_id'] . $url)]]>
</search>
<add position="before">
<![CDATA[
'thumb' => $image['thumb'],
]]>
</add>
</operation>
</file>
<!-- templates -->
<file path="catalog/view/theme/*/template/product/category.twig">
<operation error="skip">
<search>
<![CDATA[<li><a href="{{ child.href }}">{{ child.name }}</a></li>]]>
</search>
<add position="replace">
<![CDATA[
<div class="img-thumbnail text-center" style="margin-bottom: 10px;">
{% if child.thumb %}
<img src="{{ child.thumb }}" alt="{{ child.name }}" title="{{ child.name }}" class="img-responsive" />
{% endif %}
<a href="{{ child.href }}">{{ child.name }}</a>
</div>
]]>
</add>
</operation>
<operation error="skip">
<search>
<![CDATA[<li><a href="{{ category.href }}">{{ category.name }}</a></li>]]>
</search>
<add position="replace">
<![CDATA[
<div class="img-thumbnail text-center" style="margin-bottom: 10px;">
{% if category.thumb %}
<img src="{{ category.thumb }}" alt="{{ category.name }}" title="{{ category.name }}" class="img-responsive" />
{% endif %}
<a href="{{ category.href }}">{{ category.name }}</a>
</div>
]]>
</add>
</operation>
</file>
</modification>