我使用的是最新版本的 open cart。
我想要做的是在每个页面上显示来自商店类别页面的图像,因为我想将它实现到菜单中。你可以在这里明白我的意思: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 等中那么容易。
我该怎么办!?
最佳答案
好的,打开/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,你要适当的修改
关于php - OpenCart 在主页上显示类别图片?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8679580/