简体   繁体   English

Opencart 2.3.0.2:产品页面上的类别图像

[英]Opencart 2.3.0.2 : Category image on product pages

I kinda know this should be a fairly simple thing to do, but in my opencart 2.3.0.2 webshop, I want to display the category image on product pages. 我有点知道这应该是一件很简单的事情,但是在我的opencart 2.3.0.2网上商店中,我想在产品页面上显示类别图像。

But i cant find how to retrieve the image.... At this moment i have this piece of code : 但是我找不到如何检索图像...。此刻,我有这段代码:

  <div class="catthumb">
    <?php if ($thumb) { ?>
  <div class="category-bg" style="    
     background: url('<?php echo $thumb; ?>') no-repeat center center; 
     -webkit-background-size: cover;
     -moz-background-size: cover;
     -o-background-size: cover;
     background-size: cover;
     filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='.<?php echo $thumb; ?>', sizingMethod='scale');
     -ms-filter: "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='<?php echo $thumb; ?>', sizingMethod='scale')";">
  </div>
    <?php } ?>

The following code doesn't do the trick.. Ofcourse i've changed the variable along with the code. 以下代码无法解决问题。当然,我已经更改了变量和代码。

        if ($category_info) {
            if ($category_info['image']) {
            $this->data['thumbcat'] = "../image/".($category_info['image']);
            } else {
            $this->data['thumbcat'] = '';
            }
        }

But this displays the poduct thumb, instead of the category thumb, the product belongs to. 但这会显示产品所属的产品拇指,而不是类别拇指。

So the question is how to get the category image there? 因此,问题是如何获得类别图像?

Thanks in advance! 提前致谢!

Change the category image code with below code in product controller: 在产品控制器中使用以下代码更改类别图片代码:

if ($category_info) {
   if ($category_info['image']) {
      $data['thumbcat'] = "../image/".($category_info['image']);
   } else {
      $data['thumbcat'] = '';
   }
}

then use $thumbcat instead of $thumb to display category image in you product.tpl file. 然后使用$ thumbcat而不是$ thumb在product.tpl文件中显示类别图像。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM