In PS 1.6, there is a Category class, it contains some useful static methods used in your controller: getCategories(...) , getNestedCategories(...) , getSimpleCategories - all these are static (and public) that you call them Category::funcName(...)
For your purpose, I think the best option would be getNestedCategories() , which has this header:
public static function getNestedCategories( $root_category = null, $id_lang = false, $active = true, $groups = null, $use_shop_restriction = true, $sql_filter = '', $sql_sort = '', $sql_limit = '' )
In your controller, you can do something like:
$allCategories = Category::getNestedCategories(null, $this->context->language->id); $this->context->smarty->assign( 'allCategories' , $allCategories );
Then in your template file something like
{foreach from=$allCategories item=mainCategory} <div class="categoryBox"> <h2>{$mainCategory.name}</h2> <p>{$mainCategory.description}</p> </div> {foreach from=$mainCategory.children item=subCategory} <div class="categoryBox"> <h3>{$subCategory.name}</h3> <p>{$subCategory.description}</p> </div> {/foreach} {/foreach}
If you want to have only subcategories of the Home category, you can use getHomeCategories($id_lang, $active = true, $id_shop = false) :
$allCategories = Category::getHomeCategories( $this->context->language->id );
Also getCategoryInformations($ids_category, $id_lang = null) is the static function getCategoryInformations($ids_category, $id_lang = null)
=> VERY useful when you have a list of specific category identifiers that you want to receive โ you simply pass them as an array โ use case:
$myCustomCatIDs = array( 5 , 20 , 7); $myCustomCats = Category::getCategoryInformations( $myCustomCatIDs );