好的,打开/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,您应该根据需要进行更改