Opencart如何在首页展示所有带有图片的分类(Opencart 1.5.1.3)

7
在opencart 1.5.1.3中,我想要在顶部展示所有带有图片的分类,并在底部展示分类名称。当任何人点击图片或名称时,将跳转到该分类页面。
我正在尽我最大努力,即使我有一个featured.tpl文件,在主页上显示特色产品,我也试图修改它,但它没有起作用。
在featured.tpl中,我尝试更改:
<?php foreach ($products as $product) { ?>

to

<?php foreach ($categories as $category) { ?>

但是这个不起作用并显示错误。
Invalid argument supplied for foreach()

我该如何显示它?
谢谢
1个回答

9

在模板文件中不能直接使用 $categories,需要通过控制器将分类分配给视图

打开

/catalog/controller/module/featured.php

在大约第10行附近找到以下代码:

$this->load->model('catalog/product');

在它被放置之前

$this->load->model('catalog/category');
$this->data['categories'] = $this->model_catalog_category->getCategories(0);

并保存


谢谢,它可以工作,但没有显示类别的图像。我还需要做什么吗? - air
1
@air - 你尝试过如何精确地显示图像吗?你至少需要使用 $category['image']。 - Jay Gilford

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接