From 463acd37286749721b3d65db4bc73731a813e6dc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Droz?= Date: Tue, 18 Aug 2015 09:54:46 -0300 Subject: [PATCH 1/2] Make generateCategoriesMenu() a public function rather than protected. Since it's useful because someone (other module, theme, ...) could use it to display a custom category tree starting at a given level and benefit from the presentation, consistency and work already done here. Eg: > require_once("modules/blocktopmenu/blocktopmenu.php"); > $cat = Category::getNestedCategories($root, 1, false, 1); > $b = new Blocktopmenu(); > echo ($b->generateCategoriesMenu($cat)); --- blocktopmenu.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/blocktopmenu.php b/blocktopmenu.php index a7015a3..9912e2e 100644 --- a/blocktopmenu.php +++ b/blocktopmenu.php @@ -590,7 +590,7 @@ protected function generateCategoriesOption($categories, $items_to_skip = null) return $html; } - protected function generateCategoriesMenu($categories, $is_children = 0) + public function generateCategoriesMenu($categories, $is_children = 0) { $html = ''; From 169d9ce7e1e8fdcd70f2d1c7934edd3589c75126 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Droz?= Date: Tue, 18 Aug 2015 10:16:18 -0300 Subject: [PATCH 2/2] Add the ability to display disabled (inactive) categories. For common tasks of menu generation through UI and tools, disabled categories are ignored. But a custom theme could intentionally use the function to display one or more disabled categories/categorie trees. --- blocktopmenu.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/blocktopmenu.php b/blocktopmenu.php index 9912e2e..9957b48 100644 --- a/blocktopmenu.php +++ b/blocktopmenu.php @@ -590,7 +590,7 @@ protected function generateCategoriesOption($categories, $items_to_skip = null) return $html; } - public function generateCategoriesMenu($categories, $is_children = 0) + public function generateCategoriesMenu($categories, $is_children = 0, $include_disabled = FALSE) { $html = ''; @@ -603,7 +603,7 @@ public function generateCategoriesMenu($categories, $is_children = 0) } /* Whenever a category is not active we shouldnt display it to customer */ - if ((bool)$category['active'] === false) { + if ((bool)$category['active'] === false && ! $include_disabled) { continue; }