opencart - 如何在类别页面 Opencart 3 上显示带有图像的子类别
问题描述
我已经设置了 opencart3 商店。如何在类别页面中显示带有图像的子类别?
解决方案
将下面的代码复制到 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>
推荐阅读
- flask - Get Data from non-input element in Flask
- python - Pandas functions are not showing data for all the columns
- javascript - Non-typeable control characters to use as separators in text file to be read by line in javascript
- c - 如何分叉几个孩子同时计算动态过程的几个时间步长
- api - Symfony - 对象数组,对象为空
- c++ - 字符串错误向量
- javascript - where does nodejs event loop run?
- sqlite - 在 ASP.NET Core 2.1 中使用带有实体框架核心的 Sqlite 不起作用
- spring-boot - Eureka server not working properly, after while
- python - 将数字数据(保存在文本文件中)读入 python 的正确方法是什么?