public function actionRemove() { if (!CSession::isAuth()) { $this->redirectNoAccess(); } $menu = CMenuManager::getMenu(CRequest::getInt("id")); foreach ($menu->getMenuItems()->getItems() as $i) { $i->remove(); } $menu->remove(); $this->redirect("?action=index"); }
<?php $menu_str = '<ul class="nav nav-tabs nav-stacked">'; foreach (CMenuManager::getMenu("main_menu")->getMenuPublishedItemsInHierarchy()->getItems() as $item) { if ($item->getChilds()->getCount() > 0) { $menu_str .= '<li class="dropdown-submenu">'; $menu_str .= '<a class="dropdown-toggle" data-toggle="dropdown" href="#">'; $menu_str .= $item->getName(); $menu_str .= '</a>'; $menu_str .= '<ul class="dropdown-menu">'; foreach ($item->getChilds()->getItems() as $child) { $menu_str .= '<li><a tabindex="-1" title="' . htmlspecialchars($child->getName()) . '" href="' . htmlspecialchars($child->getLink()) . '">' . $child->getName() . '</a></li>'; } $menu_str .= '</ul>'; $menu_str .= '</li>'; } else { $menu_str .= '<li><a tabindex="-1" title="' . htmlspecialchars($item->getName()) . '" href="' . htmlspecialchars($item->getLink()) . '">' . $item->getName() . '</a></li>'; } } $menu_str .= '</ul>';
/** * Меню, к которому данный пункт привязан * * @return CMenu */ public function getMenu() { if (is_null($this->_menu)) { $this->_menu = CMenuManager::getMenu($this->getRecord()->getItemValue("menu_id")); } return $this->_menu; }