/** * Displays a single Status model. * @param string $slug * @return mixed */ public function actionSlug($slug) { $model = Content::find()->where(['slug' => $slug])->one(); if (!is_null($model)) { $latestPosts = Content::find()->where(['section_id' => $model->section_id])->orderBy('date DESC')->all(); return $this->render('single', ['model' => $model, 'latestPosts' => $latestPosts]); } else { return $this->redirect('/index'); } }
/** * @param string $slug * @return mixed */ public function actionSlugrubric($slug) { $rubric = ContentRubrics::find()->where(['=', 'slug', $slug])->andWhere(['=', 'section_id', 7])->one(); if (!isset($rubric->id)) { return $this->redirect('/methods'); } $query = Content::find()->where(['=', 'section_id', 7])->andWhere(['=', '`contentmanager_content`.`lang_id`', Lang::getCurrent()->id])->andWhere(['=', 'published', true])->andWhere(['=', 'rubric_id', $rubric->id])->orderBy('date DESC'); $countQuery = clone $query; $pages = new Pagination(['totalCount' => $countQuery->count(), 'pageSize' => 3]); $models = $query->offset($pages->offset)->limit($pages->limit)->all(); return $this->render('rubric', ['models' => $models, 'pages' => $pages, 'rubric' => $rubric, 'rubrics' => ContentRubrics::findBySection(7)]); }
public function publishContent() { $records = Content::find()->where(['!=', 'published', true])->where(['<', 'publication_date', $this->time])->all(); if (empty($records)) { return null; } foreach ($records as $record) { $record->published = true; $record->date = $record->publication_date; $record->save(); } }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Content::find()->orderBy(['id' => SORT_DESC])->with('section', 'rubric', 'author'); if (isset(Yii::$app->controller->module->sectionId)) { $params['ContentSearch']['section_id'] = Yii::$app->controller->module->sectionId; } $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, 'date' => $this->date, 'lang_id' => $this->lang_id, 'rubric_id' => $this->rubric_id, 'section_id' => $this->section_id]); $query->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['like', 'text', $this->text]); return $dataProvider; }
/** * Displays homepage. * * @return mixed */ public function actionIndex() { return $this->render('index', ['methodsPromo' => Content::bySection(4, 1), 'methodsLast' => Content::findLatestBySection(4, 7), 'calculatorsPromo' => Content::bySection(7, 1), 'calculatorsLast' => Content::findLatestBySection(7, 7), 'eventsPromo' => Content::bySection(8, 2), 'eventsLast' => Content::findLatestBySection(8, 7)]); }
/** * Finds the Content model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return Content the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = Content::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }
<?php use ut8ia\contentmodule\models\Content; $this->title = 'Старт'; ?> <div class="site-index"> <div class="row"> <div class="col-lg-12"> <?php echo Content::contLoc(1, 1, 'main content')->text; ?> </div> </div> </div>
<ol class="breadcrumb"><h4><?php echo Yii::t('main', 'Industrial methods of water purification :'); ?> </h4></ol> </div> </div> <?php echo BlocksWidget::widget(['items' => Content::byRubric(16, 3), 'urlHead' => 'methods/', 'itemTemplate' => 'item_preview', 'imageClass' => 'img-responsive img-hover', 'numInRow' => 3, 'rowWrapStart' => '<div class="row">', 'rowWrapEnd' => '</div>', 'textTruncate' => 140]); ?> <hr> <!-- /.row --> <div class="row"> <div class="col-lg-12"> <ol class="breadcrumb"> <h4><?php echo Yii::t('main', 'Portable and mobile technologies of water purification :'); ?> </h4> </ol> </div> </div> <?php echo BlocksWidget::widget(['items' => Content::byRubric(17, 3), 'urlHead' => 'methods/', 'itemTemplate' => 'item_preview', 'imageClass' => 'img-responsive img-hover', 'numInRow' => 3, 'rowWrapStart' => '<div class="row">', 'rowWrapEnd' => '</div>', 'textTruncate' => 140]); ?> <hr> </div>
//$lang_url = Lang::getCurrent()->url; $lang_url = ''; $base_url = Url::base() . $lang_url; $this->title = 'I-Wet : Water at net'; ?> <div class="site-wrap" style="position:absolute;width:100%;Height:100%;"> <div class="mainFrame" style="position:relative;width:100%;Height:100%;"> <div class="video-container" style="position: absolute; z-index: -1; top: 0px; left: 0px; bottom: 0px; right: 0px; overflow: hidden; background-size: cover; background-repeat: no-repeat; background-position: 50% 50%; background-image: url("http://media2.zenrus.ru/media/video/waterfall3.jpg");"> <?php echo VideoRotator::widget(['movies' => [1 => ['video/mp4' => 'http://media2.zenrus.ru/media/video/waterfall3.mp4', 'video/webm' => 'http://media2.zenrus.ru/media/video/waterfall3.webm', 'video/ogg' => 'http://media2.zenrus.ru/media/video/waterfall3.ogv'], 2 => ['video/mp4' => 'http://media2.zenrus.ru/media/video/waterfall2.mp4', 'video/webm' => 'http://media2.zenrus.ru/media/video/waterfall2.webm', 'video/ogg' => 'http://media2.zenrus.ru/media/video/waterfall2.ogv'], 3 => ['video/mp4' => 'http://media2.zenrus.ru/media/video/lake.mp4', 'video/webm' => 'http://media2.zenrus.ru/media/video/lake.webm', 'video/ogg' => 'http://media2.zenrus.ru/media/video/lake.ogv'], 4 => ['video/mp4' => 'http://media2.zenrus.ru/media/video/ocean.mp4', 'video/webm' => 'http://media2.zenrus.ru/media/video/ocean.webm', 'video/ogg' => 'http://media2.zenrus.ru/media/video/ocean.ogv'], 5 => ['video/mp4' => 'http://media2.zenrus.ru/media/video/waterfall4.mp4', 'video/webm' => 'http://media2.zenrus.ru/media/video/waterfall4.webm', 'video/ogg' => 'http://media2.zenrus.ru/media/video/waterfall4.ogv'], 6 => ['video/mp4' => 'http://media2.zenrus.ru/media/video/lake2.mp4', 'video/webm' => 'http://media2.zenrus.ru/media/video/lake2.webm', 'video/ogg' => 'http://media2.zenrus.ru/media/video/lake2.ogv'], 7 => ['video/mp4' => 'http://media2.zenrus.ru/media/video/sea2.mp4', 'video/webm' => 'http://media2.zenrus.ru/media/video/sea2.webm', 'video/ogg' => 'http://media2.zenrus.ru/media/video/sea2.ogv'], 8 => ['video/mp4' => 'http://media2.zenrus.ru/media/video/rain.mp4', 'video/webm' => 'http://media2.zenrus.ru/media/video/rain.webm', 'video/ogg' => 'http://media2.zenrus.ru/media/video/rain.ogv'], 9 => ['video/mp4' => 'http://media2.zenrus.ru/media/video/meduza.mp4', 'video/webm' => 'http://media2.zenrus.ru/media/video/meduza.webm', 'video/ogg' => 'http://media2.zenrus.ru/media/video/meduza.ogv'], 10 => ['video/mp4' => 'http://media2.zenrus.ru/media/video/raindrops.mp4', 'video/webm' => 'http://media2.zenrus.ru/media/video/raindrops.webm', 'video/ogg' => 'http://media2.zenrus.ru/media/video/raindrops.ogv']]]); ?> </div> <?php $landing = Content::contLoc(3, 3, 'landing'); ?> <div id="landingWrap" class="landingContainerWrap"> <div class="landingContainer"> <div class="landingHeader"><h1><?php echo $landing->name; ?> </h1></div> <div class="landingText"> <?php echo $landing->text; ?> </div> </div> </div> </div>
/** * @param integer $section_id * @param null|integer $limit * @return array|\yii\db\ActiveRecord[] */ public static function findLatestBySection($section_id, $limit = null, $all = null) { $ans = Content::find()->where(['section_id' => $section_id]); if (!$all) { $ans->andWhere(['=', 'published', true]); } $ans->orderBy('date DESC'); if ($limit) { $ans->limit($limit); } return $ans->all(); }