public function actionManage($menu_id) { $menu = Menu::model()->findByPk($menu_id); if (!$menu) { $this->pageNotFound(); } $root = MenuSection::model()->roots()->find('menu_id = ' . $menu_id); if (!$root) { $root = new MenuSection(); $root->menu_id = $menu->id; $root->title = $menu->name . '::корень'; $root->saveNode(); } $model = new MenuSection('search'); $model->unsetAttributes(); if (isset($_GET['MenuSection'])) { $model->attributes = $_GET['MenuSection']; } $this->render('manage', ['menu' => $menu, 'model' => $model, 'root' => $root]); }
<?php $this->page_title = $this->t('admin', 'Сортировка пунктов меню'); $this->tabs = [$this->t('admin', 'Управление пунктами меню') => $this->createUrl("manage", ['menu_id' => $menu_id])]; ?> <div class="sortable-list"> <?php $this->widget('content.portlets.NestedSortable', ['model' => MenuSection::model(), 'sortable' => true, 'root_id' => $root_id, 'id' => 'menu_section_sorting']); ?> </div>
public function getPagePath($page_id) { $section = MenuSection::model()->findByAttributes(['page_id' => $page_id, 'menu_id' => $this->id]); return $section->getPath(); }