
Лучший Ответ Cheren-dow , 13 May 2015 - 09:35
alexmixaylov, узнать есть ли вложенность можно через
$category->hasChildren()Перейти к сообщению

Лучший Ответ Cheren-dow , 13 May 2015 - 09:35
alexmixaylov, узнать есть ли вложенность можно через
$category->hasChildren()Перейти к сообщению
Отправлено 13 May 2015 - 07:29
$result = array("<ul $attribs>"); foreach ($category->getChildren($flat ? true : false) as $category) { $path = array_reverse($category->getPath()); $depth = count(array_slice($path, array_search($params->get('category', 0), $path))) - 1; if ($max_depth && $max_depth < $depth) { continue; } $current = $current_id == $category->id; $active = $current || in_array($current_id, array_keys($category->getChildren(true))); $parent = $category->hasChildren() && !($max_depth && $max_depth < $depth + 1); $url = $this->app->route->category($category, true, $menu_item); $class = ' class="' . ($flat ? '' : 'level' . $level) . ($parent ? ' parent' : '') . ($current ? ' current' : '') . ($active ? ' active' : '') . '"'; $result[] = "<li$class>"; if ($params->get('add_count', 0)) { $result[] = "<a href=\"$url\"$class><span>{$category->name} ({$category->itemCount()})</span></a>"; } else { $result[] = "<a href=\"$url\"$class><span>{$category->name}</span></a>"; } if (!$flat && ($active || $expanded) && $parent) { $result[] = $this->render($category, $params, $level + 1, $flat, 'class="level' . ($level + 1) . '"', $expanded); } $result[] = '</li>'; } $result[] = '</ul>';на яваскрипт просто сделать это, но там и так скриптов достаточно
Сообщение отредактировал alexmixaylov: 13 May 2015 - 07:36
Отправлено 13 May 2015 - 09:35 Лучший Ответ
Отправлено 13 May 2015 - 09:37