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 有人会SIRIUS 5.8.0这个软件吗
  • ¥30 comsol仿真等离激元
  • ¥15 静电纺丝煅烧后如何得到柔性纤维
  • ¥15 (标签-react native|关键词-镜像源)
  • ¥100 照片生成3D人脸视频
  • ¥15 伪装视频时长问题修改MP4的时长问题,
  • ¥15 JETSON NANO
  • ¥15 VS开发qt时如何在paintgl函数中用pushbutton控制切换纹理
  • ¥20 关于 openpyxl 处理excel文件地问题
  • ¥15 MS中不知道高分子的构型怎么构建模型