donglang2010 2016-10-24 13:15
浏览 48
已采纳

将图像添加到子类别而不是文本链接PHP-OPENCART

I am new to php, same with the opencart. I want to add image w/ link instead of the traditional list of links.

http://www.metroingeni.ro/aparatura/cantare-si-sisteme-de-cantarire

Example of where i want to implement.

  • 写回答

1条回答 默认 最新

  • dsgk0386 2016-10-24 18:34
    关注

    Ok, think I understand what you seek.

    First you need to find a controller that is responsible for category view, you can find it (I assume it's OC2) in catalog/controller/product/category.php file. Somewhere around line 160 you will see:

    $data['categories'][] = array(
        'name' => $result['name'] . ($this->config->get('config_product_count') ? ' (' . $this->model_catalog_product->getTotalProducts($filter_data) . ')' : ''),
        'href' => $this->url->link('product/category', 'path=' . $this->request->get['path'] . '_' . $result['category_id'] . $url)
    );
    

    replace it with

    $data['categories'][] = array(
        'name' => $result['name'] . ($this->config->get('config_product_count') ? ' (' . $this->model_catalog_product->getTotalProducts($filter_data) . ')' : ''),
        'href' => $this->url->link('product/category', 'path=' . $this->request->get['path'] . '_' . $result['category_id'] . $url),
        'image'=> $result['image']
    );
    

    then in your category view, located at catalog/view/theme/default/template/product/category.tpl somewhere around line 35 and 45, you can place the category image which we got from the controller earlier in a form like <?php echo $category['image']; ?>.


    <?php echo $category['image']; ?> in your view category.tpl is a relative URL of the image. Put it in your image source attribute. Must be within foreach loop of categories.

    Hope this helps, I have not tested this code but it should work.

    Default installation of opencart 2 is here assumed, but the concept should apply to any or most themes or extensions.

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

报告相同问题?

悬赏问题

  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 CSAPPattacklab
  • ¥15 一直显示正在等待HID—ISP
  • ¥15 Python turtle 画图
  • ¥15 关于大棚监测的pcb板设计
  • ¥15 stm32开发clion时遇到的编译问题
  • ¥15 lna设计 源简并电感型共源放大器
  • ¥15 如何用Labview在myRIO上做LCD显示?(语言-开发语言)
  • ¥15 Vue3地图和异步函数使用