OpenCart在主页上显示类别图像? [英] OpenCart show category images on homepage?

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

问题描述

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

I'm using the most up to date version of open cart.

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

What I'm wanting to do is show the image from the store category page on every page page, as I'm wanting to implement it into the menu. You can see what I mean here: http://www.tomrawcliffe.com/portfolio/strings-r-us/

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

In the cetegory.tpl file I found:

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

但我已经意识到这并不像复制并将其粘贴到标题中那么容易。 tpl等。

But I've come to realise that it's not as easy as copy and pasting this into the header.tpl etc.

我该怎么办!?

推荐答案

好的,打开 /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']

Then in /catalog/view/theme/[your-theme-name]/template/common/header.tpl simply use $category['thumb'] wherever you need it

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

note that I've set the width and height to 100px in the above code, and you should change it as appropriate

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

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