OpenCart在主页上显示类别图像?

use*_*925 6 php image thumbnails opencart

我正在使用最新版本的开放式购物车.

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

在cetegory.tpl文件中,我发现:

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

但我已经意识到它并不像复制和粘贴到header.tpl等那么容易.

我该怎么办!?

Jay*_*ord 12

好的,打开 /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'])
            );
Run Code Online (Sandbox Code Playgroud)

改为

            // 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'])
            );
Run Code Online (Sandbox Code Playgroud)

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

请注意,我在上面的代码中将宽度和高度设置为100px,您应该根据需要进行更改