public function printCategoryList($cat, $menu = false, $parent_str = "", $current_section = null, $current_cat = null) { if ($menu) { if ($parent_str) { $cat->title = str_ireplace($parent_str, '', $cat->title); } $cat->title = ucfirst(trim($cat->title)); $c = ''; if ($current_section === $cat->id) { $c = 'active '; } if ($current_cat === $cat->id) { $c = 'current active '; } if (isset($cat->children) && count($cat->children)) { $c .= 'parent'; } echo " <li class='{$c}'><a href='/articles/{$cat->slug}'>"; echo "{$cat->title}</a>"; if (isset($cat->children) && count($cat->children)) { echo "\n <ul>\n"; foreach ($cat->children as $child) { $this->printCategoryList($child, $menu, $cat->title, $current_section, $current_cat); } echo " </ul>\n "; } echo "</li>\n"; } else { echo "<li data-value='{$cat->id}'>{$cat->title}\n"; if (isset($cat->children) && count($cat->children)) { echo "<ul>\n"; foreach ($cat->children as $child) { articles::printCategoryList($child); } echo "</ul>\n"; } echo "</li>\n"; } }