/** * Updates an existing Category model. * If update is successful, the browser will be redirected to the 'view' page. * @param integer $id * @return mixed */ public function actionUpdate($id) { if (!$this->is_access('category/update')) { Yii::$app->session->setFlash('error', $this->errorInfo); return $this->redirect($this->redirectUrl); } $model = $this->findModel($id); $CatRecommend = new CatRecommend(); if ($model->load(Yii::$app->request->post()) && $model->save()) { // 加入分类推荐 $CatRecommend->insertRecommend($model->cat_id, $_POST['Category']['recommend_type']); // 是否需要显示在导航栏 $Nav = new Nav(); if ($model->show_in_nav == 1) { $Nav->addData('c', $model->cat_id); } else { $Nav->delData('c', $model->cat_id); } Yii::$app->session->setFlash('success', '编辑成功'); return $this->redirect(['index']); } else { $model->recommend_type = $CatRecommend->catRecommend($id); Yii::$app->view->params['meta_title'] = '编辑分类'; $catList = $model->parent(0); return $this->render('update', ['model' => $model, 'catList' => $catList]); } }
/** * Finds the Nav model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return Nav the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = Nav::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }
public function actionIndex() { $nav = Nav::find()->orderBy('order asc')->all(); return $this->render('index', ['nav' => $nav]); }
use yii\helpers\Html; use yii\widgets\ActiveForm; use common\models\Nav; /* @var $this yii\web\View */ /* @var $model common\models\NavUrl */ /* @var $form yii\widgets\ActiveForm */ ?> <div class="nav-url-form"> <?php $form = ActiveForm::begin(); ?> <?php echo $form->field($model, 'nav_id')->dropDownList(Nav::getNavList()); ?> <?php echo $form->field($model, 'title')->textInput(['maxlength' => true]); ?> <?php echo $form->field($model, 'url')->textInput(['maxlength' => true]); ?> <?php echo $form->field($model, 'description')->textInput(['maxlength' => true]); ?> <?php
public function actionOpennew($id, $status = 1) { if (!$this->is_access('navigator/update')) { exit; } $model = new Nav(); if ($model->setOpennew($id, $status)) { echo '1'; } else { echo '0'; } }
public function actionDelete() { $id = (int) \Yii::$app->request->post('id', 0); $row = Nav::find()->select('ctype,cid,type')->where($id)->one(); if ($row['type'] == 'middle' && $row['ctype'] && $row['cid']) { Nav::setShowInNav($row['ctype'], $row['cid'], 0); } if (!Nav::deleteAll('id=:id', [':id' => $id])) { exit(Json::encode(['success' => false])); } exit(Json::encode(['success' => true])); }
//'cacheSettings' => ['enableCache' => true] // normally not needed to change 'rootOptions' => ['label'=>'<span class="text-primary">计生系统</span>'], 'softDelete' => true, 'cacheSettings' => ['enableCache' => true], 'iconEditSettings'=> [ 'show' => 'list', 'listData' => [ 'folder' => 'Folder', 'file' => 'File', 'star' => 'Star', 'bell' => 'Bell', ] ], ]);*/ echo \kartik\tree\TreeView::widget(['query' => \common\models\PreferencesTree::find()->addOrderBy('root, lft'), 'headingOptions' => ['label' => '<span class="text-info">系统参数配置</span>'], 'fontAwesome' => true, 'isAdmin' => true, 'displayValue' => 1, 'softDelete' => true, 'cacheSettings' => ['enableCache' => true], 'iconEditSettings' => ['show' => 'list', 'listData' => ['folder' => 'Folder', 'file' => 'File', 'star' => 'Star', 'bell' => 'Bell']], 'nodeAddlViews' => [\kartik\tree\Module::VIEW_PART_2 => '@common/views/treemanager/_preferencesTree']]); echo \kartik\tree\TreeView::widget(['query' => \common\models\Nav::find()->addOrderBy('root, lft'), 'headingOptions' => ['label' => '<span class="text-info">系统参数配置</span>'], 'fontAwesome' => true, 'isAdmin' => true, 'displayValue' => 1, 'softDelete' => true, 'cacheSettings' => ['enableCache' => true], 'iconEditSettings' => ['show' => 'list', 'listData' => ['folder' => 'Folder', 'file' => 'File', 'star' => 'Star', 'bell' => 'Bell']], 'nodeAddlViews' => [\kartik\tree\Module::VIEW_PART_2 => '@common/views/treemanager/_nav']]); \common\widgets\JsBlock::begin(); ?> <script type="text/javascript"> $(document).ready(function() { var switcher1 = $('#switchCheck1').switcher(); var switcher2 = $('.switch').switcher(); $('#switchCheck1').switcher().on('change', function() { console.log(1111); }); $('#calendar').fullCalendar({ theme: true, header: { left: 'prev,next today', center: 'title', right: 'month,agendaWeek,agendaDay'
/** * 是否新窗口打开状态修改 * @param $id * @param int $status * @return bool|int */ public function setOpennew($id, $status = 1) { if (!in_array($status, [0, 1])) { return false; } return Nav::updateAll(['opennew' => $status], 'id = :id', [':id' => $id]); }
/** * 修改分类 是否在导航栏显示 的状态 * @param $cat_id * @param int $status * @return bool|int */ public function show_in_nav($cat_id, $status = 1) { if (!in_array($status, [0, 1])) { return false; } $result = Category::updateAll(['show_in_nav' => $status], 'cat_id = :cat_id', [':cat_id' => $cat_id]); if ($result) { $Nav = new Nav(); if ($status == 1) { // 新增 $Nav->addData('c', $cat_id); } else { // 删除 $Nav->delData('c', $cat_id); } return true; } return false; }