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

发布于 2024-12-23 14:47:52 字数 517 浏览 3 评论 0原文

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

我想要做的是在每个页面上显示商店类别页面的图像,因为我想将其实现到菜单中。您可以在这里明白我的意思: 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 } ?>

但我开始意识到这并不像将其复制并粘贴到 header.tpl 等中那么容易。

我该怎么办!?

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

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/

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 } ?>

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

What do I do!?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

用心笑 2024-12-30 14:47:52

好的,打开 /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,您应该更改它酌情

OK, open up /catalog/controller/common/header.php

Find this code

            // 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'])
            );

change it to

            // 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'])
            );

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

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文