/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Gallery::find(); $dataProvider = new ActiveDataProvider(['query' => $query]); if (!($this->load($params) && $this->validate())) { return $dataProvider; } $query->andFilterWhere(['id' => $this->id, 'table_id' => $this->table_id, 'parent' => $this->parent, 'parent_id' => $this->parent_id, 'status' => $this->status, 'createdby' => $this->createdby, 'createdon' => $this->createdon, 'like' => $this->like, 'dislike' => $this->dislike, 'views' => $this->views, 'rate' => $this->rate, 'rate_num' => $this->rate_num]); $query->andFilterWhere(['like', 'table_name', $this->table_name])->andFilterWhere(['like', 'image', $this->image])->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['like', 'introtext', $this->introtext])->andFilterWhere(['like', 'content', $this->content]); $query->orderBy('sort'); return $dataProvider; }
/** * Finds the Gallery model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return Gallery the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = Gallery::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }
<div id="main-content"> <div class="kopa-area kopa-area-1"> <div class="wrapper"> <div class="row"> <div class="col-md-8 col-sm-8 col-xs-12"> <div class="kopa-sync-portfolio-widget"> <div class="owl-carousel sync3"> <?php foreach (Gallery::findAll(['table_id' => $model->id, 'status' => Gallery::STATUS_PUBLISHED]) as $element) { ?> <div class="item"> <div class="entry-thumb"> <?php echo Html::img(Image::thumb($element->image, 757, 413)); ?> </div> </div> <?php } ?> </div> <!-- carousel sync 3 -->
?> </h1> <div class="lead"> <p><?php echo $model->introtext; ?> </p> </div> <!-- End Text --> <!-- Media Gallery --> <div class="blog-media mt-40 mb-40 mb-xs-30"> <ul class="clearlist content-slider"> <?php foreach (Gallery::find()->where(['table_id' => $model->id, 'table_name' => 'content', 'status' => Gallery::STATUS_PUBLISHED])->orderBy('sort asc')->all() as $element) { ?> <li><?php echo Html::img(Image::thumb($element->image, 945, 532)); ?> </li <?php } ?> </ul> </div> <p><?php echo $model->content; ?>
//use kartik\datecontrol\DateControl; use common\themes\admin\widgets\ActiveForm; use andreosoft\summernote\Summernote; use common\modules\catalog\models\CatalogProducts; use common\modules\catalog\models\CatalogCategorys; use common\modules\filemanager\widgets\Image; use yii\grid\CheckboxColumn; use yii\widgets\ListView; use common\themes\admin\widgets\GridView; use common\themes\admin\widgets\GridViewEdited; use common\modules\comments\models\CommentsSearch; use common\modules\gallery\models\GallerySearch; use common\modules\gallery\widgets\Galleryinline; use common\themes\admin\widgets\ActionColumn; use common\modules\filemanager\widgets\ImageColumn; use yii\helpers\Url; ?> <?php $form = ActiveForm::begin(['options' => ['enctype' => 'multipart/form-data', 'boxTitle' => $options['title'], 'buttonUndo' => $options['buttonUndo']]]); ?> <?php echo Tabs::widget(['options' => ['class' => 'nav-tabs-custom'], 'items' => [['label' => \Yii::t('catalog/main', 'Main'), 'content' => $form->field($model, 'name')->textInput(['maxlength' => 255]) . $form->field($model, 'introtext')->widget(Summernote::className(), ['editorOptions' => ['height' => 200]]) . $form->field($model, 'content')->widget(Summernote::className(), ['editorOptions' => ['height' => 400]]), 'active' => true], ['label' => \Yii::t('catalog/main', 'Info'), 'content' => $form->field($model, 'tag')->textInput(['maxlength' => 255]) . $form->field($model, 'image')->widget(Image::className()) . $form->field($model, 'price')->textInput(['maxlength' => 11]) . $form->field($model, 'price_d')->textInput(['maxlength' => 11]) . $form->field($model, 'discont')->dropDownList([0 => Yii::t('catalog/main', 'No'), 1 => Yii::t('catalog/main', 'Yes')])], ['label' => \Yii::t('catalog/main', 'Seo'), 'content' => $form->field($model, 'seo_url')->textInput(['maxlength' => 255]) . $form->field($model, 'seo_title')->textInput(['maxlength' => 255]) . $form->field($model, 'seo_description')->textarea() . $form->field($model, 'seo_keyword')->textInput(['maxlength' => 255])], ['label' => \Yii::t('catalog/main', 'Manager'), 'content' => $form->field($model, 'isparent')->dropDownList([0 => Yii::t('catalog/main', 'No'), 1 => Yii::t('catalog/main', 'Yes')]) . $form->field($model, 'parent')->dropDownList(ArrayHelper::merge(['0' => 'No'], ArrayHelper::map(CatalogProducts::find()->where(['isparent' => '1'])->all(), 'id', 'fullname'))) . $form->field($model, 'status')->dropDownList(CatalogProducts::getStatusArray()) . $form->field($model, 'publishedondate')->widget(DatePicker::className()) . $form->field($model, 'publishedontime')->textInput() . $form->field($model, 'sort')->textInput()], ['label' => 'Comments', 'content' => isset($model->id) ? \common\themes\admin\widgets\GridViewEdited::widget(['dataProvider' => (new CommentsSearch())->search(['CommentsSearch' => ['table_name' => 'catalog', 'table_id' => $model->id]]), 'actionUpdate' => Url::to(['/comments/backend/update']), 'createModel' => new \common\modules\comments\models\Comments(), 'defaultValue' => ['Comments[table_id]' => $model->id, 'Comments[table_name]' => 'catalog'], 'columns' => [['attribute' => 'status', 'value' => function ($model) { return Html::activeDropDownList($model, 'status', ['Unpublished', 'Published'], ['class' => 'form-control', 'style' => 'width:100%;', 'prompt' => 'Выберите']); }], ['attribute' => 'content'], ['class' => \common\themes\admin\widgets\ActionColumn::className(), 'template' => '{delete}', 'controller' => '/comments/backend']]]) : '<div class="alert alert-warning alert-dismissable">' . '<button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>' . '<h4><i class="icon fa fa-warning"></i> Внимение!</h4>' . \Yii::t('catalog/main', 'Save befor use it') . '</div>' . Html::submitButton('Save', ['class' => 'btn btn-success'])], ['label' => \Yii::t('catalog/main', 'Gallery'), 'content' => isset($model->id) ? \common\themes\admin\widgets\GridViewEdited::widget(['dataProvider' => (new \common\modules\gallery\models\GallerySearch())->search(['GallerySearch' => ['table_name' => 'catalog', 'table_id' => $model->id]]), 'actionUpdate' => Url::to(['/gallery/backend/update']), 'createModel' => new \common\modules\gallery\models\Gallery(), 'defaultValue' => ['Gallery[table_id]' => $model->id, 'Gallery[table_name]' => 'catalog'], 'columns' => [['class' => common\modules\filemanager\widgets\ImageColumn::className(), 'attribute' => 'image'], ['attribute' => 'status', 'value' => function ($model) { return Html::activeDropDownList($model, 'status', \common\modules\gallery\models\Gallery::getStatusArray(), ['class' => 'form-control', 'style' => 'width:100%;', 'prompt' => 'Выберите']); }], 'content', 'sort', ['class' => \common\themes\admin\widgets\ActionColumn::className(), 'template' => '{delete}', 'controller' => '/gallery/backend']]]) : '<div class="alert alert-warning alert-dismissable">' . '<button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>' . '<h4><i class="icon fa fa-warning"></i> Внимение!</h4>' . \Yii::t('catalog/main', 'Save befor use it') . '</div>' . Html::submitButton('Save', ['class' => 'btn btn-success'])]]]); ?> <?php ActiveForm::end();
public function run() { $model = new Gallery(); $elements = $model->find()->where("table_id = {$this->id} AND table_name = '{$this->table_name}'")->all(); return $this->render('getGalleryElements/index', ['elements' => $elements]); }