簡體   English   中英

OpenCart 在主頁上顯示類別圖像?

[英]OpenCart show category images on homepage?

我正在使用最新版本的開放式購物車。

我想要做的是在每個頁面頁面上顯示來自商店類別頁面的圖像,因為我想將它實施到菜單中。 你可以在這里看到我的意思: 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 等中那么容易。

我該怎么辦!?

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,您應該根據需要進行更改

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM