How to build category tree including sub-cats
Greetings,
I'm working on coding a new Bootstrap 4 Header nav bar, incorporating the Smartmenus for Bootstrap plugin, and wish to create a categories dropdown menu, including all sub-cats.
I would like to leverage existing ZC 1.5.7b classes/functions for generating a category tree array that I can loop through and style with the Bootstrap/Smartmenus css classes.
I've been looking at the category_tree class and some of the code within the categories sidebox, but my limited understanding of how to use the category_tree class, I can only seem to get an array with just top level cats. See my test code snippet below.
PHP Code:
$main_category_tree = new category_tree;
$box_categories_array = array();
// don't build a tree when no categories
$check_categories = $db->Execute("select categories_id from " . TABLE_CATEGORIES . " where categories_status=1 limit 1");
if ($check_categories->RecordCount() > 0) {
$box_categories_array = $main_category_tree->zen_category_tree();
}
for ($i = 0, $j = count($box_categories_array); $i < $j; $i++) {
echo $box_categories_array[$i]['name'].' => is top: '.$box_categories_array[$i]['top'].' => has sub: '.$box_categories_array[$i]['has_sub_cat'].'<br>';
}
Would using the zen_categories_ul_generator class be a better start and just str_replace in my css classes?
Any help with this would be much appreciated!
Thanks...
Experience is what you get when you don’t get what you want…
Bookmarks