public function actionLinks($categories_id = null, $id = null, $parent = null, $action = null)
 {
     $category = Categories::findOne($categories_id);
     if ($id) {
         $link = Links::findOne($id);
     } else {
         $link = new Links();
         $link->categories_id = $categories_id;
         $link->parent = $parent;
         $link->state = 1;
     }
     if ($link->load(Yii::$app->request->post()) && $link->save()) {
         if (!$link->contents) {
             $content = new Contents();
             $content->links_id = $link->id;
             $content->seq = 1;
             $content->save();
         }
         Yii::$app->getSession()->setFlash('success', 'Изменения приняты');
         return $this->redirect(['', 'categories_id' => $categories_id, 'id' => $link->id, 'action' => $action]);
     }
     return $this->render('links', compact('category', 'link'));
 }
Example #2
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getCategory()
 {
     return $this->hasOne(Categories::className(), ['id' => 'categories_id']);
 }
Example #3
0
<?php

use common\models\main\Categories;
/** @var $this \yii\web\View */
$items[] = ['label' => 'Категории сайта', 'options' => ['class' => 'header']];
foreach (Categories::find()->where(['visible' => 1])->orderBy(['seq' => SORT_ASC])->all() as $category) {
    $items[] = ['label' => $category->comment, 'icon' => 'fa fa-sitemap', 'url' => ['/map/links', 'categories_id' => $category->id], 'active' => $this->context->module->id == 'map' && Yii::$app->request->get('categories_id') == $category->id ? true : false];
}
$items[] = ['label' => 'Дополнительно', 'options' => ['class' => 'header']];
$items[] = ['label' => 'Редиректы', 'icon' => 'fa fa-reply', 'url' => '#'];
$items[] = ['label' => 'Шаблоны', 'icon' => 'fa fa-circle-thin', 'url' => '#'];
$items[] = ['label' => 'Виды', 'icon' => 'fa fa-circle-thin', 'url' => '#'];
?>
<aside class="main-sidebar">

    <section class="sidebar">
        <?php 
echo dmstr\widgets\Menu::widget(['options' => ['class' => 'sidebar-menu'], 'items' => $items]);
?>

    </section>

</aside>