Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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

like image 522
air Avatar asked Oct 14 '11 18:10

air


1 Answers

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

like image 95
Jay Gilford Avatar answered Nov 13 '22 07:11

Jay Gilford