Commit 2851dba90e177418885b9ece6b5a9dd7b0effc20
1 parent
b4dfc61c
slider
Showing
18 changed files
with
987 additions
and
7 deletions
Show diff stats
| 1 | +<?php | |
| 2 | + | |
| 3 | + namespace backend\controllers; | |
| 4 | + | |
| 5 | + use artbox\core\models\Slide; | |
| 6 | + use artbox\core\models\Slider; | |
| 7 | + use artbox\core\models\SlideSearch; | |
| 8 | + use Yii; | |
| 9 | + use yii\filters\AccessControl; | |
| 10 | + use yii\web\Controller; | |
| 11 | + use yii\web\NotFoundHttpException; | |
| 12 | + use yii\filters\VerbFilter; | |
| 13 | + | |
| 14 | + /** | |
| 15 | + * SlideController implements the CRUD actions for Slide model. | |
| 16 | + */ | |
| 17 | + class SlideController extends Controller | |
| 18 | + { | |
| 19 | + /** | |
| 20 | + * @inheritdoc | |
| 21 | + */ | |
| 22 | + public function behaviors() | |
| 23 | + { | |
| 24 | + return [ | |
| 25 | + 'access' => [ | |
| 26 | + 'class' => AccessControl::className(), | |
| 27 | + 'rules' => [ | |
| 28 | + [ | |
| 29 | + 'actions' => [ | |
| 30 | + 'login', | |
| 31 | + 'error', | |
| 32 | + ], | |
| 33 | + 'allow' => true, | |
| 34 | + ], | |
| 35 | + [ | |
| 36 | + 'allow' => true, | |
| 37 | + 'roles' => [ '@' ], | |
| 38 | + ], | |
| 39 | + ], | |
| 40 | + ], | |
| 41 | + 'verbs' => [ | |
| 42 | + 'class' => VerbFilter::className(), | |
| 43 | + 'actions' => [ | |
| 44 | + 'delete' => [ 'POST' ], | |
| 45 | + ], | |
| 46 | + ], | |
| 47 | + ]; | |
| 48 | + } | |
| 49 | + | |
| 50 | + /** | |
| 51 | + * Lists all Slide models. | |
| 52 | + * | |
| 53 | + * @param int $slider_id | |
| 54 | + * | |
| 55 | + * @return mixed | |
| 56 | + */ | |
| 57 | + public function actionIndex($slider_id) | |
| 58 | + { | |
| 59 | + $slider = $this->findSlider($slider_id); | |
| 60 | + $searchModel = new SlideSearch(); | |
| 61 | + $dataProvider = $searchModel->search(Yii::$app->request->queryParams, $slider); | |
| 62 | + | |
| 63 | + return $this->render( | |
| 64 | + 'index', | |
| 65 | + [ | |
| 66 | + 'searchModel' => $searchModel, | |
| 67 | + 'dataProvider' => $dataProvider, | |
| 68 | + 'slider' => $slider, | |
| 69 | + ] | |
| 70 | + ); | |
| 71 | + } | |
| 72 | + | |
| 73 | + /** | |
| 74 | + * Displays a single Slide model. | |
| 75 | + * | |
| 76 | + * @param integer $id | |
| 77 | + * | |
| 78 | + * @return mixed | |
| 79 | + */ | |
| 80 | + public function actionView($id) | |
| 81 | + { | |
| 82 | + return $this->render( | |
| 83 | + 'view', | |
| 84 | + [ | |
| 85 | + 'model' => $this->findModel($id), | |
| 86 | + ] | |
| 87 | + ); | |
| 88 | + } | |
| 89 | + | |
| 90 | + /** | |
| 91 | + * Creates a new Slide model. | |
| 92 | + * If creation is successful, the browser will be redirected to the 'view' page. | |
| 93 | + * | |
| 94 | + * @param int $slider_id | |
| 95 | + * | |
| 96 | + * @return mixed | |
| 97 | + */ | |
| 98 | + public function actionCreate(int $slider_id) | |
| 99 | + { | |
| 100 | + $slider = $this->findSlider($slider_id); | |
| 101 | + | |
| 102 | + $model = new Slide(); | |
| 103 | + $model->generateLangs(); | |
| 104 | + | |
| 105 | + if ($model->loadWithLangs(\Yii::$app->request)) { | |
| 106 | + if ($model->saveWithLangs()) { | |
| 107 | + return $this->redirect( | |
| 108 | + [ | |
| 109 | + 'view', | |
| 110 | + 'id' => $model->id, | |
| 111 | + ] | |
| 112 | + ); | |
| 113 | + } | |
| 114 | + } | |
| 115 | + return $this->render( | |
| 116 | + 'create', | |
| 117 | + [ | |
| 118 | + 'model' => $model, | |
| 119 | + 'modelLangs' => $model->modelLangs, | |
| 120 | + 'slider' => $slider, | |
| 121 | + ] | |
| 122 | + ); | |
| 123 | + } | |
| 124 | + | |
| 125 | + /** | |
| 126 | + * Updates an existing Slide model. | |
| 127 | + * If update is successful, the browser will be redirected to the 'view' page. | |
| 128 | + * | |
| 129 | + * @param integer $id | |
| 130 | + * | |
| 131 | + * @return mixed | |
| 132 | + */ | |
| 133 | + public function actionUpdate($id) | |
| 134 | + { | |
| 135 | + $model = $this->findModel($id); | |
| 136 | + $model->generateLangs(); | |
| 137 | + | |
| 138 | + $slider = $this->findSlider($model->slider_id); | |
| 139 | + | |
| 140 | + if ($model->loadWithLangs(\Yii::$app->request)) { | |
| 141 | + if ($model->saveWithLangs()) { | |
| 142 | + return $this->redirect( | |
| 143 | + [ | |
| 144 | + 'view', | |
| 145 | + 'id' => $model->id, | |
| 146 | + ] | |
| 147 | + ); | |
| 148 | + } | |
| 149 | + } | |
| 150 | + return $this->render( | |
| 151 | + 'update', | |
| 152 | + [ | |
| 153 | + 'model' => $model, | |
| 154 | + 'modelLangs' => $model->modelLangs, | |
| 155 | + 'slider' => $slider, | |
| 156 | + ] | |
| 157 | + ); | |
| 158 | + } | |
| 159 | + | |
| 160 | + /** | |
| 161 | + * Deletes an existing Slide model. | |
| 162 | + * If deletion is successful, the browser will be redirected to the 'index' page. | |
| 163 | + * | |
| 164 | + * @param integer $id | |
| 165 | + * | |
| 166 | + * @return mixed | |
| 167 | + */ | |
| 168 | + public function actionDelete($id) | |
| 169 | + { | |
| 170 | + $model = $this->findModel($id); | |
| 171 | + | |
| 172 | + $slider_id = $model->slider_id; | |
| 173 | + $model->delete(); | |
| 174 | + return $this->redirect( | |
| 175 | + [ | |
| 176 | + 'index', | |
| 177 | + 'slider_id' => $slider_id, | |
| 178 | + ] | |
| 179 | + ); | |
| 180 | + } | |
| 181 | + | |
| 182 | + /** | |
| 183 | + * Finds the Slide model based on its primary key value. | |
| 184 | + * If the model is not found, a 404 HTTP exception will be thrown. | |
| 185 | + * | |
| 186 | + * @param integer $id | |
| 187 | + * | |
| 188 | + * @return Slide the loaded model | |
| 189 | + * @throws NotFoundHttpException if the model cannot be found | |
| 190 | + */ | |
| 191 | + protected function findModel($id) | |
| 192 | + { | |
| 193 | + if (( $model = Slide::findOne($id) ) !== null) { | |
| 194 | + return $model; | |
| 195 | + } else { | |
| 196 | + throw new NotFoundHttpException('The requested page does not exist.'); | |
| 197 | + } | |
| 198 | + } | |
| 199 | + | |
| 200 | + /** | |
| 201 | + * Finds the Slider model based on its primary key value. | |
| 202 | + * If the model is not found, a 404 HTTP exception will be thrown. | |
| 203 | + * | |
| 204 | + * @param integer $id | |
| 205 | + * | |
| 206 | + * @return Slider the loaded model | |
| 207 | + * @throws NotFoundHttpException if the model cannot be found | |
| 208 | + */ | |
| 209 | + protected function findSlider($id) | |
| 210 | + { | |
| 211 | + if (( $model = Slider::findOne($id) ) !== null) { | |
| 212 | + return $model; | |
| 213 | + } else { | |
| 214 | + throw new NotFoundHttpException('The requested page does not exist.'); | |
| 215 | + } | |
| 216 | + } | |
| 217 | + } | ... | ... |
| 1 | +<?php | |
| 2 | + | |
| 3 | + namespace backend\controllers; | |
| 4 | + | |
| 5 | + use artbox\core\models\Slider; | |
| 6 | + use artbox\core\models\SliderSearch; | |
| 7 | + use Yii; | |
| 8 | + use yii\filters\AccessControl; | |
| 9 | + use yii\web\Controller; | |
| 10 | + use yii\web\NotFoundHttpException; | |
| 11 | + use yii\filters\VerbFilter; | |
| 12 | + | |
| 13 | + /** | |
| 14 | + * SliderController implements the CRUD actions for Slider model. | |
| 15 | + */ | |
| 16 | + class SliderController extends Controller | |
| 17 | + { | |
| 18 | + /** | |
| 19 | + * @inheritdoc | |
| 20 | + */ | |
| 21 | + public function behaviors() | |
| 22 | + { | |
| 23 | + return [ | |
| 24 | + 'access' => [ | |
| 25 | + 'class' => AccessControl::className(), | |
| 26 | + 'rules' => [ | |
| 27 | + [ | |
| 28 | + 'actions' => [ | |
| 29 | + 'login', | |
| 30 | + 'error', | |
| 31 | + ], | |
| 32 | + 'allow' => true, | |
| 33 | + ], | |
| 34 | + [ | |
| 35 | + 'allow' => true, | |
| 36 | + 'roles' => [ '@' ], | |
| 37 | + ], | |
| 38 | + ], | |
| 39 | + ], | |
| 40 | + 'verbs' => [ | |
| 41 | + 'class' => VerbFilter::className(), | |
| 42 | + 'actions' => [ | |
| 43 | + 'delete' => [ 'POST' ], | |
| 44 | + ], | |
| 45 | + ], | |
| 46 | + ]; | |
| 47 | + } | |
| 48 | + | |
| 49 | + /** | |
| 50 | + * Lists all Slider models. | |
| 51 | + * | |
| 52 | + * @return mixed | |
| 53 | + */ | |
| 54 | + public function actionIndex() | |
| 55 | + { | |
| 56 | + $searchModel = new SliderSearch(); | |
| 57 | + $dataProvider = $searchModel->search(Yii::$app->request->queryParams); | |
| 58 | + | |
| 59 | + return $this->render( | |
| 60 | + 'index', | |
| 61 | + [ | |
| 62 | + 'searchModel' => $searchModel, | |
| 63 | + 'dataProvider' => $dataProvider, | |
| 64 | + ] | |
| 65 | + ); | |
| 66 | + } | |
| 67 | + | |
| 68 | + /** | |
| 69 | + * Displays a single Slider model. | |
| 70 | + * | |
| 71 | + * @param integer $id | |
| 72 | + * | |
| 73 | + * @return mixed | |
| 74 | + */ | |
| 75 | + public function actionView($id) | |
| 76 | + { | |
| 77 | + return $this->render( | |
| 78 | + 'view', | |
| 79 | + [ | |
| 80 | + 'model' => $this->findModel($id), | |
| 81 | + ] | |
| 82 | + ); | |
| 83 | + } | |
| 84 | + | |
| 85 | + /** | |
| 86 | + * Creates a new Slider model. | |
| 87 | + * If creation is successful, the browser will be redirected to the 'view' page. | |
| 88 | + * | |
| 89 | + * @return mixed | |
| 90 | + */ | |
| 91 | + public function actionCreate() | |
| 92 | + { | |
| 93 | + $model = new Slider(); | |
| 94 | + | |
| 95 | + if ($model->load(Yii::$app->request->post()) && $model->save()) { | |
| 96 | + return $this->redirect( | |
| 97 | + [ | |
| 98 | + 'view', | |
| 99 | + 'id' => $model->id, | |
| 100 | + ] | |
| 101 | + ); | |
| 102 | + } else { | |
| 103 | + return $this->render( | |
| 104 | + 'create', | |
| 105 | + [ | |
| 106 | + 'model' => $model, | |
| 107 | + ] | |
| 108 | + ); | |
| 109 | + } | |
| 110 | + } | |
| 111 | + | |
| 112 | + /** | |
| 113 | + * Updates an existing Slider model. | |
| 114 | + * If update is successful, the browser will be redirected to the 'view' page. | |
| 115 | + * | |
| 116 | + * @param integer $id | |
| 117 | + * | |
| 118 | + * @return mixed | |
| 119 | + */ | |
| 120 | + public function actionUpdate($id) | |
| 121 | + { | |
| 122 | + $model = $this->findModel($id); | |
| 123 | + | |
| 124 | + if ($model->load(Yii::$app->request->post()) && $model->save()) { | |
| 125 | + return $this->redirect( | |
| 126 | + [ | |
| 127 | + 'view', | |
| 128 | + 'id' => $model->id, | |
| 129 | + ] | |
| 130 | + ); | |
| 131 | + } else { | |
| 132 | + return $this->render( | |
| 133 | + 'update', | |
| 134 | + [ | |
| 135 | + 'model' => $model, | |
| 136 | + ] | |
| 137 | + ); | |
| 138 | + } | |
| 139 | + } | |
| 140 | + | |
| 141 | + /** | |
| 142 | + * Deletes an existing Slider model. | |
| 143 | + * If deletion is successful, the browser will be redirected to the 'index' page. | |
| 144 | + * | |
| 145 | + * @param integer $id | |
| 146 | + * | |
| 147 | + * @return mixed | |
| 148 | + */ | |
| 149 | + public function actionDelete($id) | |
| 150 | + { | |
| 151 | + $this->findModel($id) | |
| 152 | + ->delete(); | |
| 153 | + | |
| 154 | + return $this->redirect([ 'index' ]); | |
| 155 | + } | |
| 156 | + | |
| 157 | + /** | |
| 158 | + * Finds the Slider model based on its primary key value. | |
| 159 | + * If the model is not found, a 404 HTTP exception will be thrown. | |
| 160 | + * | |
| 161 | + * @param integer $id | |
| 162 | + * | |
| 163 | + * @return Slider the loaded model | |
| 164 | + * @throws NotFoundHttpException if the model cannot be found | |
| 165 | + */ | |
| 166 | + protected function findModel($id) | |
| 167 | + { | |
| 168 | + if (( $model = Slider::findOne($id) ) !== null) { | |
| 169 | + return $model; | |
| 170 | + } else { | |
| 171 | + throw new NotFoundHttpException('The requested page does not exist.'); | |
| 172 | + } | |
| 173 | + } | |
| 174 | + } | ... | ... |
backend/views/layouts/menu_items.php
| 1 | +<?php | |
| 2 | + | |
| 3 | + use artbox\core\models\Slide; | |
| 4 | + use artbox\core\widgets\LanguageForm; | |
| 5 | + use yii\helpers\Html; | |
| 6 | + use yii\widgets\ActiveForm; | |
| 7 | + | |
| 8 | + /** | |
| 9 | + * @var \yii\web\View $this | |
| 10 | + * @var Slide $model | |
| 11 | + * @var \artbox\core\models\SlideLang[] $modelLangs | |
| 12 | + * @var ActiveForm $form | |
| 13 | + * @var \artbox\core\models\Slider $slider | |
| 14 | + */ | |
| 15 | +?> | |
| 16 | + | |
| 17 | +<div class="slide-form"> | |
| 18 | + | |
| 19 | + <?php $form = ActiveForm::begin(); ?> | |
| 20 | + | |
| 21 | + <?= $form->field($model, 'slider_id') | |
| 22 | + ->hiddenInput([ 'value' => $slider->id ]) | |
| 23 | + ->label(false) ?> | |
| 24 | + | |
| 25 | + <?= LanguageForm::widget( | |
| 26 | + [ | |
| 27 | + 'modelLangs' => $modelLangs, | |
| 28 | + 'formView' => '@artbox/core/views/slide/_form_language', | |
| 29 | + 'form' => $form, | |
| 30 | + ] | |
| 31 | + ) ?> | |
| 32 | + | |
| 33 | + <?= $form->field($model, 'status') | |
| 34 | + ->checkbox( | |
| 35 | + [ | |
| 36 | + 'class' => 'flat', | |
| 37 | + ] | |
| 38 | + ) ?> | |
| 39 | + | |
| 40 | + <?= $form->field($model, 'sort') | |
| 41 | + ->input('number') ?> | |
| 42 | + | |
| 43 | + <div class="form-group"> | |
| 44 | + <?= Html::submitButton( | |
| 45 | + $model->isNewRecord ? Yii::t('core', 'Create') : Yii::t('core', 'Update'), | |
| 46 | + [ 'class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary' ] | |
| 47 | + ) ?> | |
| 48 | + </div> | |
| 49 | + | |
| 50 | + <?php ActiveForm::end(); ?> | |
| 51 | + | |
| 52 | +</div> | ... | ... |
| 1 | +<?php | |
| 2 | + use artbox\core\components\imagemanager\components\ImageManagerInputWidget; | |
| 3 | + use artbox\core\models\Language; | |
| 4 | + use dosamigos\tinymce\TinyMce; | |
| 5 | + use yii\web\View; | |
| 6 | + use yii\widgets\ActiveForm; | |
| 7 | + | |
| 8 | + /** | |
| 9 | + * @var \artbox\core\models\SlideLang $model_lang | |
| 10 | + * @var Language $language | |
| 11 | + * @var ActiveForm $form | |
| 12 | + * @var View $this | |
| 13 | + */ | |
| 14 | + echo $form->field($model_lang, '[' . $language->id . ']image_id') | |
| 15 | + ->widget( | |
| 16 | + ImageManagerInputWidget::className(), | |
| 17 | + [ | |
| 18 | + 'aspectRatio' => ( 16 / 9 ), | |
| 19 | + //set the aspect ratio | |
| 20 | + 'showPreview' => true, | |
| 21 | + //false to hide the preview | |
| 22 | + 'showDeletePickedImageConfirm' => false, | |
| 23 | + //on true show warning before detach image | |
| 24 | + ] | |
| 25 | + ); | |
| 26 | + echo $form->field($model_lang, '[' . $language->id . ']title') | |
| 27 | + ->textInput([ 'maxlength' => true ]); | |
| 28 | + echo $form->field($model_lang, '[' . $language->id . ']link') | |
| 29 | + ->textInput([ 'maxlength' => true ]); | |
| 30 | +?> | |
| 0 | 31 | \ No newline at end of file | ... | ... |
| 1 | +<?php | |
| 2 | + | |
| 3 | + use artbox\core\models\SlideSearch; | |
| 4 | + use yii\helpers\Html; | |
| 5 | + use yii\widgets\ActiveForm; | |
| 6 | + | |
| 7 | + /* @var $this yii\web\View */ | |
| 8 | + /* @var $model SlideSearch */ | |
| 9 | + /* @var $form yii\widgets\ActiveForm */ | |
| 10 | +?> | |
| 11 | + | |
| 12 | +<div class="slide-search"> | |
| 13 | + | |
| 14 | + <?php $form = ActiveForm::begin( | |
| 15 | + [ | |
| 16 | + 'action' => [ 'index' ], | |
| 17 | + 'method' => 'get', | |
| 18 | + ] | |
| 19 | + ); ?> | |
| 20 | + | |
| 21 | + <?= $form->field($model, 'id') ?> | |
| 22 | + | |
| 23 | + <?= $form->field($model, 'slider_id') ?> | |
| 24 | + | |
| 25 | + <?= $form->field($model, 'status') | |
| 26 | + ->checkbox() ?> | |
| 27 | + | |
| 28 | + <?= $form->field($model, 'sort') ?> | |
| 29 | + | |
| 30 | + <div class="form-group"> | |
| 31 | + <?= Html::submitButton(Yii::t('core', 'Search'), [ 'class' => 'btn btn-primary' ]) ?> | |
| 32 | + <?= Html::resetButton(Yii::t('core', 'Reset'), [ 'class' => 'btn btn-default' ]) ?> | |
| 33 | + </div> | |
| 34 | + | |
| 35 | + <?php ActiveForm::end(); ?> | |
| 36 | + | |
| 37 | +</div> | ... | ... |
| 1 | +<?php | |
| 2 | + | |
| 3 | + use artbox\core\models\Slide; | |
| 4 | + use yii\helpers\Html; | |
| 5 | + | |
| 6 | + /** | |
| 7 | + * @var \yii\web\View $this | |
| 8 | + * @var Slide $model | |
| 9 | + * @var \artbox\core\models\Slider $slider | |
| 10 | + * @var \artbox\core\models\SlideLang[] $modelLangs | |
| 11 | + */ | |
| 12 | + | |
| 13 | + $this->title = Yii::t('core', 'Create Slide'); | |
| 14 | + $this->params[ 'breadcrumbs' ][] = [ | |
| 15 | + 'label' => Yii::t('core', 'Slides'), | |
| 16 | + 'url' => [ | |
| 17 | + 'index', | |
| 18 | + 'slider_id' => $slider->id, | |
| 19 | + ], | |
| 20 | + ]; | |
| 21 | + $this->params[ 'breadcrumbs' ][] = $this->title; | |
| 22 | +?> | |
| 23 | +<div class="slide-create"> | |
| 24 | + | |
| 25 | + <h1><?= Html::encode($this->title) ?></h1> | |
| 26 | + | |
| 27 | + <?= $this->render( | |
| 28 | + '_form', | |
| 29 | + [ | |
| 30 | + 'model' => $model, | |
| 31 | + 'modelLangs' => $modelLangs, | |
| 32 | + 'slider' => $slider, | |
| 33 | + ] | |
| 34 | + ) ?> | |
| 35 | + | |
| 36 | +</div> | ... | ... |
| 1 | +<?php | |
| 2 | + | |
| 3 | + use artbox\core\models\SlideSearch; | |
| 4 | + use yii\helpers\Html; | |
| 5 | + use yii\grid\GridView; | |
| 6 | + | |
| 7 | + /* @var $this yii\web\View */ | |
| 8 | + /* @var $searchModel SlideSearch */ | |
| 9 | + /* @var $dataProvider yii\data\ActiveDataProvider */ | |
| 10 | + /* @var \artbox\core\models\Slider $slider */ | |
| 11 | + | |
| 12 | + $this->title = Yii::t('core', 'Slides'); | |
| 13 | + $this->params[ 'breadcrumbs' ][] = $this->title; | |
| 14 | +?> | |
| 15 | +<div class="slide-index"> | |
| 16 | + | |
| 17 | + <h1><?= Html::encode($this->title) ?></h1> | |
| 18 | + <?php // echo $this->render('_search', ['model' => $searchModel]); ?> | |
| 19 | + | |
| 20 | + <p> | |
| 21 | + <?= Html::a(Yii::t('core', 'Create Slide'), | |
| 22 | + [ | |
| 23 | + 'create', | |
| 24 | + 'slider_id' => $slider->id, | |
| 25 | + ], | |
| 26 | + [ 'class' => 'btn btn-success' ] | |
| 27 | + ) ?> | |
| 28 | + </p> | |
| 29 | + <?= GridView::widget( | |
| 30 | + [ | |
| 31 | + 'dataProvider' => $dataProvider, | |
| 32 | + 'filterModel' => $searchModel, | |
| 33 | + 'columns' => [ | |
| 34 | + [ 'class' => 'yii\grid\SerialColumn' ], | |
| 35 | + | |
| 36 | + 'id', | |
| 37 | + [ | |
| 38 | + 'attribute' => 'image_id', | |
| 39 | + 'value' => function (\artbox\core\models\Slide $model) { | |
| 40 | + if (empty($model->lang->image)) { | |
| 41 | + return ''; | |
| 42 | + } else { | |
| 43 | + return Html::img( | |
| 44 | + $model->lang->image->getUrl(), | |
| 45 | + [ | |
| 46 | + 'width' => '400px', | |
| 47 | + ] | |
| 48 | + ); | |
| 49 | + } | |
| 50 | + }, | |
| 51 | + 'format' => 'html', | |
| 52 | + ], | |
| 53 | + 'status:boolean', | |
| 54 | + 'sort', | |
| 55 | + | |
| 56 | + [ 'class' => 'yii\grid\ActionColumn' ], | |
| 57 | + ], | |
| 58 | + ] | |
| 59 | + ); ?> | |
| 60 | +</div> | ... | ... |
| 1 | +<?php | |
| 2 | + | |
| 3 | + use artbox\core\models\Slide; | |
| 4 | + use yii\helpers\Html; | |
| 5 | + | |
| 6 | + /** | |
| 7 | + * @var \yii\web\View $this | |
| 8 | + * @var Slide $model | |
| 9 | + * @var \artbox\core\models\Slider $slider | |
| 10 | + * @var \artbox\core\models\SlideLang[] $modelLangs | |
| 11 | + */ | |
| 12 | + | |
| 13 | + $this->title = Yii::t( | |
| 14 | + 'core', | |
| 15 | + 'Update {modelClass}: ', | |
| 16 | + [ | |
| 17 | + 'modelClass' => 'Slide', | |
| 18 | + ] | |
| 19 | + ) . $model->id; | |
| 20 | + $this->params[ 'breadcrumbs' ][] = [ | |
| 21 | + 'label' => Yii::t('core', 'Slides'), | |
| 22 | + 'url' => [ | |
| 23 | + 'index', | |
| 24 | + 'slider_id' => $slider->id, | |
| 25 | + ], | |
| 26 | + ]; | |
| 27 | + $this->params[ 'breadcrumbs' ][] = [ | |
| 28 | + 'label' => $model->id, | |
| 29 | + 'url' => [ | |
| 30 | + 'view', | |
| 31 | + 'id' => $model->id, | |
| 32 | + ], | |
| 33 | + ]; | |
| 34 | + $this->params[ 'breadcrumbs' ][] = Yii::t('core', 'Update'); | |
| 35 | +?> | |
| 36 | +<div class="slide-update"> | |
| 37 | + | |
| 38 | + <h1><?= Html::encode($this->title) ?></h1> | |
| 39 | + | |
| 40 | + <?= $this->render( | |
| 41 | + '_form', | |
| 42 | + [ | |
| 43 | + 'model' => $model, | |
| 44 | + 'modelLangs' => $modelLangs, | |
| 45 | + 'slider' => $slider, | |
| 46 | + ] | |
| 47 | + ) ?> | |
| 48 | + | |
| 49 | +</div> | ... | ... |
| 1 | +<?php | |
| 2 | + | |
| 3 | + use artbox\core\models\Slide; | |
| 4 | + use yii\helpers\Html; | |
| 5 | + use yii\widgets\DetailView; | |
| 6 | + | |
| 7 | + /* @var $this yii\web\View */ | |
| 8 | + /* @var $model Slide */ | |
| 9 | + | |
| 10 | + $this->title = $model->id; | |
| 11 | + $this->params[ 'breadcrumbs' ][] = [ | |
| 12 | + 'label' => Yii::t('core', 'Slides'), | |
| 13 | + 'url' => [ | |
| 14 | + 'index', | |
| 15 | + 'slider_id' => $model->slider_id, | |
| 16 | + ], | |
| 17 | + ]; | |
| 18 | + $this->params[ 'breadcrumbs' ][] = $this->title; | |
| 19 | +?> | |
| 20 | +<div class="slide-view"> | |
| 21 | + | |
| 22 | + <h1><?= Html::encode($this->title) ?></h1> | |
| 23 | + | |
| 24 | + <p> | |
| 25 | + <?= Html::a( | |
| 26 | + Yii::t('core', 'Update'), | |
| 27 | + [ | |
| 28 | + 'update', | |
| 29 | + 'id' => $model->id, | |
| 30 | + ], | |
| 31 | + [ 'class' => 'btn btn-primary' ] | |
| 32 | + ) ?> | |
| 33 | + <?= Html::a( | |
| 34 | + Yii::t('core', 'Delete'), | |
| 35 | + [ | |
| 36 | + 'delete', | |
| 37 | + 'id' => $model->id, | |
| 38 | + ], | |
| 39 | + [ | |
| 40 | + 'class' => 'btn btn-danger', | |
| 41 | + 'data' => [ | |
| 42 | + 'confirm' => Yii::t('core', 'Are you sure you want to delete this item?'), | |
| 43 | + 'method' => 'post', | |
| 44 | + ], | |
| 45 | + ] | |
| 46 | + ) ?> | |
| 47 | + </p> | |
| 48 | + | |
| 49 | + <?= DetailView::widget( | |
| 50 | + [ | |
| 51 | + 'model' => $model, | |
| 52 | + 'attributes' => [ | |
| 53 | + 'id', | |
| 54 | + 'slider_id', | |
| 55 | + 'status:boolean', | |
| 56 | + 'sort', | |
| 57 | + ], | |
| 58 | + ] | |
| 59 | + ) ?> | |
| 60 | + | |
| 61 | +</div> | ... | ... |
| 1 | +<?php | |
| 2 | + | |
| 3 | + use artbox\core\models\Slider; | |
| 4 | + use yii\helpers\Html; | |
| 5 | + use yii\widgets\ActiveForm; | |
| 6 | + | |
| 7 | + /* @var $this yii\web\View */ | |
| 8 | + /* @var $model Slider */ | |
| 9 | + /* @var $form yii\widgets\ActiveForm */ | |
| 10 | +?> | |
| 11 | + | |
| 12 | +<div class="slider-form"> | |
| 13 | + | |
| 14 | + <?php $form = ActiveForm::begin(); ?> | |
| 15 | + | |
| 16 | + <?= $form->field($model, 'status') | |
| 17 | + ->checkbox([ | |
| 18 | + 'class' => 'flat', | |
| 19 | + ]) ?> | |
| 20 | + | |
| 21 | + <?= $form->field($model, 'sort') | |
| 22 | + ->input('number') ?> | |
| 23 | + | |
| 24 | + <div class="form-group"> | |
| 25 | + <?= Html::submitButton( | |
| 26 | + $model->isNewRecord ? Yii::t('core', 'Create') : Yii::t('core', 'Update'), | |
| 27 | + [ 'class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary' ] | |
| 28 | + ) ?> | |
| 29 | + </div> | |
| 30 | + | |
| 31 | + <?php ActiveForm::end(); ?> | |
| 32 | + | |
| 33 | +</div> | ... | ... |
| 1 | +<?php | |
| 2 | + | |
| 3 | + use artbox\core\models\SliderSearch; | |
| 4 | + use yii\helpers\Html; | |
| 5 | + use yii\widgets\ActiveForm; | |
| 6 | + | |
| 7 | + /* @var $this yii\web\View */ | |
| 8 | + /* @var $model SliderSearch */ | |
| 9 | + /* @var $form yii\widgets\ActiveForm */ | |
| 10 | +?> | |
| 11 | + | |
| 12 | +<div class="slider-search"> | |
| 13 | + | |
| 14 | + <?php $form = ActiveForm::begin( | |
| 15 | + [ | |
| 16 | + 'action' => [ 'index' ], | |
| 17 | + 'method' => 'get', | |
| 18 | + ] | |
| 19 | + ); ?> | |
| 20 | + | |
| 21 | + <?= $form->field($model, 'id') ?> | |
| 22 | + | |
| 23 | + <?= $form->field($model, 'status') | |
| 24 | + ->checkbox() ?> | |
| 25 | + | |
| 26 | + <?= $form->field($model, 'sort') ?> | |
| 27 | + | |
| 28 | + <div class="form-group"> | |
| 29 | + <?= Html::submitButton(Yii::t('core', 'Search'), [ 'class' => 'btn btn-primary' ]) ?> | |
| 30 | + <?= Html::resetButton(Yii::t('core', 'Reset'), [ 'class' => 'btn btn-default' ]) ?> | |
| 31 | + </div> | |
| 32 | + | |
| 33 | + <?php ActiveForm::end(); ?> | |
| 34 | + | |
| 35 | +</div> | ... | ... |
| 1 | +<?php | |
| 2 | + | |
| 3 | + use artbox\core\models\Slider; | |
| 4 | + use yii\helpers\Html; | |
| 5 | + | |
| 6 | + /* @var $this yii\web\View */ | |
| 7 | + /* @var $model Slider */ | |
| 8 | + | |
| 9 | + $this->title = Yii::t('core', 'Create Slider'); | |
| 10 | + $this->params[ 'breadcrumbs' ][] = [ | |
| 11 | + 'label' => Yii::t('core', 'Sliders'), | |
| 12 | + 'url' => [ 'index' ], | |
| 13 | + ]; | |
| 14 | + $this->params[ 'breadcrumbs' ][] = $this->title; | |
| 15 | +?> | |
| 16 | +<div class="slider-create"> | |
| 17 | + | |
| 18 | + <h1><?= Html::encode($this->title) ?></h1> | |
| 19 | + | |
| 20 | + <?= $this->render( | |
| 21 | + '_form', | |
| 22 | + [ | |
| 23 | + 'model' => $model, | |
| 24 | + ] | |
| 25 | + ) ?> | |
| 26 | + | |
| 27 | +</div> | ... | ... |
| 1 | +<?php | |
| 2 | + | |
| 3 | + use artbox\core\models\SliderSearch; | |
| 4 | + use yii\helpers\Html; | |
| 5 | + use yii\grid\GridView; | |
| 6 | + | |
| 7 | + /* @var $this yii\web\View */ | |
| 8 | + /* @var $searchModel SliderSearch */ | |
| 9 | + /* @var $dataProvider yii\data\ActiveDataProvider */ | |
| 10 | + | |
| 11 | + $this->title = Yii::t('core', 'Sliders'); | |
| 12 | + $this->params[ 'breadcrumbs' ][] = $this->title; | |
| 13 | +?> | |
| 14 | +<div class="slider-index"> | |
| 15 | + | |
| 16 | + <h1><?= Html::encode($this->title) ?></h1> | |
| 17 | + <?php // echo $this->render('_search', ['model' => $searchModel]); ?> | |
| 18 | + | |
| 19 | + <p> | |
| 20 | + <?= Html::a(Yii::t('core', 'Create Slider'), [ 'create' ], [ 'class' => 'btn btn-success' ]) ?> | |
| 21 | + </p> | |
| 22 | + <?= GridView::widget( | |
| 23 | + [ | |
| 24 | + 'dataProvider' => $dataProvider, | |
| 25 | + 'filterModel' => $searchModel, | |
| 26 | + 'columns' => [ | |
| 27 | + [ 'class' => 'yii\grid\SerialColumn' ], | |
| 28 | + | |
| 29 | + 'id', | |
| 30 | + 'status:boolean', | |
| 31 | + [ | |
| 32 | + 'attribute' => 'sort', | |
| 33 | + 'filter' => false, | |
| 34 | + ], | |
| 35 | + [ | |
| 36 | + 'class' => 'yii\grid\ActionColumn', | |
| 37 | + 'buttons' => [ | |
| 38 | + 'slides' => function ($url, $model, $key) { | |
| 39 | + /** | |
| 40 | + * @var \artbox\core\models\Slider $model | |
| 41 | + */ | |
| 42 | + return Html::a( | |
| 43 | + Html::tag( | |
| 44 | + 'i', | |
| 45 | + '', | |
| 46 | + [ | |
| 47 | + 'class' => 'glyphicon glyphicon-picture', | |
| 48 | + ] | |
| 49 | + ), | |
| 50 | + [ | |
| 51 | + 'slide/index', | |
| 52 | + 'slider_id' => $model->id, | |
| 53 | + ], | |
| 54 | + [ | |
| 55 | + 'title' => \Yii::t('core', 'Slides'), | |
| 56 | + 'data' => [ | |
| 57 | + 'pjax' => 0, | |
| 58 | + ], | |
| 59 | + ] | |
| 60 | + ); | |
| 61 | + }, | |
| 62 | + ], | |
| 63 | + 'template' => '{slides} {view} {update} {delete}', | |
| 64 | + ], | |
| 65 | + ], | |
| 66 | + ] | |
| 67 | + ); ?> | |
| 68 | +</div> | ... | ... |
| 1 | +<?php | |
| 2 | + | |
| 3 | + use artbox\core\models\Slider; | |
| 4 | + use yii\helpers\Html; | |
| 5 | + | |
| 6 | + /* @var $this yii\web\View */ | |
| 7 | + /* @var $model Slider */ | |
| 8 | + | |
| 9 | + $this->title = Yii::t( | |
| 10 | + 'core', | |
| 11 | + 'Update {modelClass}: ', | |
| 12 | + [ | |
| 13 | + 'modelClass' => 'Slider', | |
| 14 | + ] | |
| 15 | + ) . $model->id; | |
| 16 | + $this->params[ 'breadcrumbs' ][] = [ | |
| 17 | + 'label' => Yii::t('core', 'Sliders'), | |
| 18 | + 'url' => [ 'index' ], | |
| 19 | + ]; | |
| 20 | + $this->params[ 'breadcrumbs' ][] = [ | |
| 21 | + 'label' => $model->id, | |
| 22 | + 'url' => [ | |
| 23 | + 'view', | |
| 24 | + 'id' => $model->id, | |
| 25 | + ], | |
| 26 | + ]; | |
| 27 | + $this->params[ 'breadcrumbs' ][] = Yii::t('core', 'Update'); | |
| 28 | +?> | |
| 29 | +<div class="slider-update"> | |
| 30 | + | |
| 31 | + <h1><?= Html::encode($this->title) ?></h1> | |
| 32 | + | |
| 33 | + <?= $this->render( | |
| 34 | + '_form', | |
| 35 | + [ | |
| 36 | + 'model' => $model, | |
| 37 | + ] | |
| 38 | + ) ?> | |
| 39 | + | |
| 40 | +</div> | ... | ... |
| 1 | +<?php | |
| 2 | + | |
| 3 | + use artbox\core\models\Slider; | |
| 4 | + use yii\helpers\Html; | |
| 5 | + use yii\widgets\DetailView; | |
| 6 | + | |
| 7 | + /* @var $this yii\web\View */ | |
| 8 | + /* @var $model Slider */ | |
| 9 | + | |
| 10 | + $this->title = $model->id; | |
| 11 | + $this->params[ 'breadcrumbs' ][] = [ | |
| 12 | + 'label' => Yii::t('core', 'Sliders'), | |
| 13 | + 'url' => [ 'index' ], | |
| 14 | + ]; | |
| 15 | + $this->params[ 'breadcrumbs' ][] = $this->title; | |
| 16 | +?> | |
| 17 | +<div class="slider-view"> | |
| 18 | + | |
| 19 | + <h1><?= Html::encode($this->title) ?></h1> | |
| 20 | + | |
| 21 | + <p> | |
| 22 | + <?= Html::a( | |
| 23 | + Yii::t('core', 'Update'), | |
| 24 | + [ | |
| 25 | + 'update', | |
| 26 | + 'id' => $model->id, | |
| 27 | + ], | |
| 28 | + [ 'class' => 'btn btn-primary' ] | |
| 29 | + ) ?> | |
| 30 | + <?= Html::a( | |
| 31 | + Yii::t('core', 'Delete'), | |
| 32 | + [ | |
| 33 | + 'delete', | |
| 34 | + 'id' => $model->id, | |
| 35 | + ], | |
| 36 | + [ | |
| 37 | + 'class' => 'btn btn-danger', | |
| 38 | + 'data' => [ | |
| 39 | + 'confirm' => Yii::t('core', 'Are you sure you want to delete this item?'), | |
| 40 | + 'method' => 'post', | |
| 41 | + ], | |
| 42 | + ] | |
| 43 | + ) ?> | |
| 44 | + </p> | |
| 45 | + | |
| 46 | + <?= DetailView::widget( | |
| 47 | + [ | |
| 48 | + 'model' => $model, | |
| 49 | + 'attributes' => [ | |
| 50 | + 'id', | |
| 51 | + 'status:boolean', | |
| 52 | + 'sort', | |
| 53 | + ], | |
| 54 | + ] | |
| 55 | + ) ?> | |
| 56 | + | |
| 57 | +</div> | ... | ... |
frontend/controllers/SiteController.php
| ... | ... | @@ -7,6 +7,7 @@ |
| 7 | 7 | use artbox\catalog\models\Product; |
| 8 | 8 | use artbox\core\models\DummyAlias; |
| 9 | 9 | use artbox\core\models\Feedback; |
| 10 | + use artbox\core\models\Slide; | |
| 10 | 11 | use artbox\order\models\LoginForm; |
| 11 | 12 | use artbox\order\models\PasswordResetRequestForm; |
| 12 | 13 | use artbox\order\models\ResetPasswordForm; |
| ... | ... | @@ -117,6 +118,7 @@ |
| 117 | 118 | ) |
| 118 | 119 | ->limit(4) |
| 119 | 120 | ->all(); |
| 121 | + $slider = Slide::find()->with('lang.image')->where(['status' => true])->orderBy('sort')->all(); | |
| 120 | 122 | return $this->render( |
| 121 | 123 | 'index', |
| 122 | 124 | [ |
| ... | ... | @@ -128,6 +130,7 @@ |
| 128 | 130 | 'brandCount' => $brandCount, |
| 129 | 131 | 'brands' => $brands, |
| 130 | 132 | 'articles' => $articles, |
| 133 | + 'slider' => $slider | |
| 131 | 134 | ] |
| 132 | 135 | ); |
| 133 | 136 | } | ... | ... |
frontend/views/site/index.php
| ... | ... | @@ -48,15 +48,11 @@ _________________________________________________________ --> |
| 48 | 48 | <div class="dark-mask"></div> |
| 49 | 49 | |
| 50 | 50 | <div class="homepage owl-carousel main_slider sliders_"> |
| 51 | + <?php foreach ($slider as $item){?> | |
| 51 | 52 | <div class="item"> |
| 52 | - <a href="#"><img src="../img/market_banner.png" alt=""></a> | |
| 53 | - </div> | |
| 54 | - <div class="item"> | |
| 55 | - <a href="#"><img src="../img/market_banner.png" alt=""></a> | |
| 56 | - </div> | |
| 57 | - <div class="item"> | |
| 58 | - <a href="#"><img src="../img/market_banner.png" alt=""></a> | |
| 53 | + <a href="<?=$item->lang->link?>"><img src="<?=$item->lang->image->getUrl()?>" alt=""></a> | |
| 59 | 54 | </div> |
| 55 | + <?php } ?> | |
| 60 | 56 | </div> |
| 61 | 57 | <!-- /.project owl-slider --> |
| 62 | 58 | </div> | ... | ... |