dsa80833 2016-08-11 14:08
浏览 61
已采纳

在opencart中的链接文本下显示类别图像

I’ve used OpenCart v2.2.0.0 for a client’s website as it was their eCommerce system of choice. We have gotten a lot of the preliminary design added onto the website - that's not a problem.

The issue we are having is with the category pages.

Currently, the subcategories are displaying as normal text links: http://i.imgur.com/1LORcrg.jpg

What we would like to accomplish is to feed through unique images underneath these links.

What I had in mind was whether it was possible to feed the category image below the text, so that it looks similar to this: http://i.imgur.com/zTv2hHN.jpg

Is this possible within this version of OpenCart?

Any help would be much appreciated.

Cheers, Euan

  • 写回答

1条回答 默认 最新

  • dongxie3681 2016-08-11 22:17
    关注

    Step 1: Go to catalog\view\theme\THEMEACTIVE\template\product\category.tpl Find following line of code (in default theme there are in two places)

    <?php foreach ($categories as $category) { ?><li>
    

    Then add following lines of code (if in default then add on both places)

    <a href="<?php echo $category['href']; ?>">
                <img src="<?php echo $category['category_image']; ?>" />
              </a>
    

    Step 2: Go to catalog\controller\product\category.php Find following lines of code:

    $data['categories'][] = array(
                    'name' => $result['name'] . ($this->config->get('config_product_count') ? ' (' . $this->model_catalog_product->getTotalProducts($filter_data) . ')' : ''),
    

    Add following lines of code just below it:

    'category_image' =>$this->model_tool_image->resize($result['image'], 200,200),
    

    Here 200 is the size of image, first is width and second is height. Save and it will show images

    Better to make OCMOD for it. Instead of directly writing code in core file.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 乘性高斯噪声在深度学习网络中的应用
  • ¥15 运筹学排序问题中的在线排序
  • ¥15 关于docker部署flink集成hadoop的yarn,请教个问题 flink启动yarn-session.sh连不上hadoop,这个整了好几天一直不行,求帮忙看一下怎么解决
  • ¥30 求一段fortran代码用IVF编译运行的结果
  • ¥15 深度学习根据CNN网络模型,搭建BP模型并训练MNIST数据集
  • ¥15 C++ 头文件/宏冲突问题解决
  • ¥15 用comsol模拟大气湍流通过底部加热(温度不同)的腔体
  • ¥50 安卓adb backup备份子用户应用数据失败
  • ¥20 有人能用聚类分析帮我分析一下文本内容嘛
  • ¥30 python代码,帮调试,帮帮忙吧