Howdy,
I'm trying to find out how to display a list of categories (parents and children in a hierarchy, with links) on header.tpl of my theme. Either by using PHP or an add-on. Any ideas?
Thanks in advance!
Does anybody know if this 'feature' is being added to a new release of OpenCart. We also used the mentioned code to create a page to show all the products on 1 page.
OpenCart is the best Webshop tool! Congratulations with releasing version 1.5
Out lead programmer got it sorted. This has only been tested on OpenCart 1.5.1.
Enjoy.
Enjoy.
Code: Select all
<?php
//.. Load the category Model (model_catalog_category)
//.. Load in root categories, and loop through as "$Category"
$this->load->model('catalog/category');
?>
<ul>
<?php foreach($this->model_catalog_category->getCategories(0) as $Category): ?>
<li><a href="index.php?route=product/category&path=<?php echo $Category['category_id'] ?>"><?php echo $Category['name'] ?></a>
<?php $SubCategories = $this->model_catalog_category->getCategories($Category['category_id']) ?>
<?php if( count($SubCategories) > 0 ): ?>
<ul>
<?php foreach( $SubCategories as $SubCategory ): ?>
<li><a href="index.php?route=product/category&path=<?php echo $SubCategory['category_id'] ?>"><?php echo $SubCategory['name'] ?></a></li>
<?php endforeach; ?>
</ul>
<?php endif; ?>
</li>
<?php endforeach; ?>
</ul>
Who is online
Users browsing this forum: No registered users and 125 guests