OpenCart在主页上显示类别图像


OpenCart show category images on homepage?

我使用的是最新版本的open cart。

我想做的是在每个页面页面上显示来自商店类别页面的图像,因为我想将其实现到菜单中。你可以看到我的意思:http://www.tomrawcliffe.com/portfolio/strings-r-us/

在分类中。tpl文件我找到了:

<?php if ($thumb) { ?>
    <div class="image"><img src="<?php echo $thumb; ?>" alt="<?php echo $heading_title; ?    >" /></div>
<?php } ?>

但我已经意识到,它不像复制和粘贴到标题那么容易。TPL等

我该怎么办!?

OK,打开/catalog/controller/common/header.php

查找此代码

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

改为

            // Level 1
            $this->load->model('tool/image');
            $image = empty($category['image']) ? 'no_image.jpg' : $category['image'];
            $thumb = $this->model_tool_image->resize($image, 100, 100);
            $this->data['categories'][] = array(
                'name'     => $category['name'],
                'children' => $children_data,
                'column'   => $category['column'] ? $category['column'] : 1,
                'thumb'    => $thumb,
                'href'     => $this->url->link('product/category', 'path=' . $category['category_id'])
            );

然后在/catalog/view/theme/[your-theme-name]/template/common/header.tpl中只需在需要的地方使用$category['thumb']

请注意,我在上面的代码中设置了宽度和高度为100px,你应该适当地改变它