2011-12-30 110 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

相关问题