2011-12-30 38 views
6

我正在使用最新版本的打開購物車。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 } ?> 

但我已經認識到,它不是一份容易粘貼到頁眉這一點。 tpl等。

我該怎麼做!?

回答

11

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']無論你需要它

注意,我已經設定了寬度和heig在上面的代碼ht到100px,你應該適當地改變它

+0

我試圖解釋我的最好,但沒有完全得到它。我想要的是要在菜單中顯示的類別圖像以及類別名稱。我只想要父類別圖像,而不是子類。那還好嗎? – user1122925 2011-12-30 15:21:54

+0

看看上面的那個,應該回答你需要的東西 – 2011-12-30 17:12:52

+0

你絕對的傳奇!謝謝。 – user1122925 2012-01-04 15:23:06