/** * Displays homepage. * * @return mixed */ public function actionIndex() { $query = Content::find()->where(['=', 'section_id', 2])->andWhere(['=', '`contentmanager_content`.`lang_id`', Lang::getCurrent()->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('index', ['models' => $models, 'pages' => $pages]); return $this->render('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 getLangUrl() { if ($this->_lang_url === null) { $this->_lang_url = $this->getUrl(); $url_list = explode('/', $this->_lang_url); $lang_url = isset($url_list[1]) ? $url_list[1] : null; Lang::setCurrent($lang_url); if ($lang_url !== null && $lang_url === Lang::getCurrent()->url && strpos($this->_lang_url, Lang::getCurrent()->url) === 1) { $this->_lang_url = substr($this->_lang_url, strlen(Lang::getCurrent()->url) + 1); } } return $this->_lang_url; }
public function createUrl($params) { if (isset($params['lang_id'])) { //Если указан идентификатор языка, то делаем попытку найти язык в БД, //иначе работаем с языком по умолчанию $lang = Lang::findOne($params['lang_id']); if ($lang === null) { $lang = Lang::getDefaultLang(); } unset($params['lang_id']); } else { //Если не указан параметр языка, то работаем с текущим языком $lang = Lang::getCurrent(); } //Получаем сформированный URL(без префикса идентификатора языка) $url = parent::createUrl($params); //Добавляем к URL префикс - буквенный идентификатор языка if ($url == '/') { return '/' . $lang->url; } else { return '/' . $lang->url . $url; } }
public function run() { return $this->render('lang/view', ['current' => Lang::getCurrent(), 'langs' => Lang::find()->all()]); }
<?php use ut8ia\multylang\models\Lang; use yii\helpers\Html; /* @var $this yii\web\View */ /* @var $model ut8ia\contentmodule\models\Content */ $this->title = Yii::t('app', 'Create Content'); $this->params['breadcrumbs'][] = ['label' => Yii::t('app', 'Content'), 'url' => ['index']]; $this->params['breadcrumbs'][] = $this->title; // lang id to current $model->lang_id = Lang::getCurrent()->id; ?> <div class="content-create"> <?php echo $this->render('_form', ['model' => $model]); ?> </div>
<?php /* @var $this yii\web\View */ use ut8ia\multylang\models\Lang; $lang_url = Lang::getCurrent()->url; $this->title = 'I-Wet : Health at net'; ?> <!--<iframe src="https://www.google.com/maps/embed?pb=!1m14!1m12!1m3!1d657525.7109506081!2d32.40240907432744!3d49.92771297065197!2m3!1f0!2f0!3f0!3m2!1i1024!2i768!4f13.1!5e0!3m2!1sru!2sua!4v1449233967344" width="600" height="450" frameborder="0" style="border:0" allowfullscreen></iframe>--> <div class="container"> <!-- Page Heading/Breadcrumbs --> <div class="row"> <div class="col-lg-12"> <h1 class="page-header">Places <small>of clear water</small> </h1> <ol class="breadcrumb"> <li><a href="index.html">Home</a> </li> <li class="active">find or checkout places with good water or equipment</li> </ol> </div> </div> <!-- /.row --> <!-- Content Row --> <div class="row"> <!-- Map Column --> <div class="col-md-8"> <!-- Embedded Google Map -->
/** * tags collection for the content * @return array */ public function collection() { return Content::find()->asArray()->with('tags')->where(['=', '`contentmanager_content`.`lang_id`', Lang::getCurrent()->id])->all(); }