如何在OpenCart中显示类别图像 [英] How to display Category images in OpenCart

查看:55
本文介绍了如何在OpenCart中显示类别图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

控制器中的我的category.php模块:

My categories.php module in controller:

        $this->data['categories'][] = array(
            'category_id'       => $category['category_id'],
            'name'              => $category['name'],
            'image'             => $category['image'],
            'children'          => $children_data,              
            'href'              => $this->url->link('product/category', 'path=' . $category['category_id'])
        );  

/products/(查看)中的我的category.tpl

My categories.tpl in /products/ (View)

  <?php foreach ($categories as $category) { ?>
  <li><a href="<?php echo $category['href']; ?>"><img src="<?php echo $category['image']; ?>" alt="<?php echo $category['name']; ?>"></a></li>
  <?php } ?>

但是它只是给我一个错误,指出变量未知.

However it just gives me an error saying that the variable is unknown.

我做错什么了吗?

推荐答案

  1. 第一个问题是您编辑了错误的控制器文件,如果要使更改显示在该特定视图中,则应编辑controller/product/category.php.

  1. The First problem is that you are editing the wrong controller file, you should edit the controller/product/category.php if you want your changes to appear in that specific view.

图像不会按原样显示,因为它没有作为完整的URL保存在数据库中:

The images will not appear as it is since it is not saved as a full url in the database:

由=> $category['image']

应为=> DIR_IMAGE.$category['image']

希望这可以解决您的问题.

Hope this solves your answer.

这篇关于如何在OpenCart中显示类别图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆