/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Settings::find(); $dataProvider = new ActiveDataProvider(['query' => $query]); $this->load($params); if (!$this->validate()) { // uncomment the following line if you do not want to return any records when validation fails // $query->where('0=1'); return $dataProvider; } $query->andFilterWhere(['id' => $this->id, 'active' => $this->active, 'created' => $this->created, 'modified' => $this->modified]); $query->andFilterWhere(['like', 'type', $this->type])->andFilterWhere(['like', 'section', $this->section])->andFilterWhere(['like', 'key', $this->key])->andFilterWhere(['like', 'value', $this->value]); return $dataProvider; }
/** * Finds the Settings model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return Settings the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = Settings::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }
<?php $this->beginBody(); ?> <?php echo GhostHtml::a(Html::img(Yii::$app->homeUrl . 'css/system_images/go_admin.png'), ['/content/content-page/index'], ['style' => 'position:absolute; z-index: 99999; top: 0; left: 0']); ?> <?php echo Breadcrumbs::widget(['links' => isset($this->params['breadcrumbs']) ? $this->params['breadcrumbs'] : []]); ?> <?php echo $content; ?> <?php echo Settings::getModel()->enable_seo_tracking == 1 ? Settings::getModel()->seo_tracking_script : ''; ?> <?php use raoul2000\widget\scrollup\Scrollup; Scrollup::widget(['theme' => Scrollup::THEME_IMAGE, 'pluginOptions' => ['scrollText' => "To top", 'topDistance' => 400, 'topSpeed' => 3000, 'animation' => Scrollup::ANIMATION_SLIDE, 'animationInSpeed' => 200, 'animationOutSpeed' => 200, 'activeOverlay' => false]]); $this->endBody(); ?> </body> </html> <?php $this->endPage();
/** * @param string $scenario * * @return Settings */ protected function getSettingsModel($scenario) { $model = Settings::getModel(); $model->scenario = $scenario; return $model; }
<?php // echo $this->render('_search', ['model' => $searchModel]); ?> <p> <?php echo Html::a('Create Settings', ['create'], ['class' => 'btn btn-success']); ?> </p> <?php Pjax::begin(); ?> <?php echo GridView::widget(['dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'columns' => ['id', ['attribute' => 'section', 'filter' => ArrayHelper::map(Settings::find()->select('section')->distinct()->where(['<>', 'section', ''])->all(), 'section', 'section')], 'key', 'value:ntext', ['class' => '\\pheme\\grid\\ToggleColumn', 'attribute' => 'active', 'filter' => [1 => Yii::t('yii', 'Yes'), 0 => Yii::t('yii', 'No')]], ['class' => 'yii\\grid\\ActionColumn']]]); ?> <?php Pjax::end(); ?> <?php echo SettingsWidget::widget(['title' => 'Settings']); ?> </div>