开发者

opencart how to display all categories with images on home page opencart 1.5.1.3

开发者 https://www.devze.com 2023-04-13 06:52 出处:网络
in opencart 1.5.1.3 i want to display allcategories with images at top andcategory name at botoom. once any one click on image or name will goto that category page.

in opencart 1.5.1.3 i want to display all categories with images at top and category name at botoom.

once any one click on image or name will goto that category page.

i am trying my best, even i have featured.tpl file, which is showing featured products on home page, i also try to modify it but its not working.

in featured.tpl i try to change

<?php foreach ($products as $product) { ?>

开发者_运维百科to

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

but this is not working and displaying error

Invalid argument supplied for foreach()

how can i display that?

Thanks


You can't just use $categories in the tpl file, you have to assign the categories to the view using the controller

Open

/catalog/controller/module/featured.php

Find this line around line 10

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

Before it put

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

And save

0

精彩评论

暂无评论...
验证码 换一张
取 消