Пример #1
0
 public static function getBlockContent($id, $language)
 {
     /** @var Block $model */
     $model = Block::findOne($id);
     return !is_null($model) ? $model->getContent($language, '') : '';
 }
Пример #2
0
 /**
  * Finds the Block model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param string $id
  * @return Block the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Block::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
Пример #3
0
 public function actionPage()
 {
     $request = Yii::$app->request;
     $block = null;
     if ($code = $request->get('code')) {
         $block = Block::find()->where(['url_code' => $code])->one();
         if (is_null($block)) {
             $block = Block::findOne($code);
         }
     }
     if (!is_null($block)) {
         return $this->render('page', ['model' => $block]);
     } else {
         return $this->goHome();
     }
 }
Пример #4
0
 /**
  * Finds the Block model based on its slug value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param string $slug
  * @return Block the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModelBySlug($slug)
 {
     if (($model = Block::findOne(['slug' => $slug])) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
Пример #5
0
 /**
  * Finds the Link model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Link the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Block::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException(Yii::t('app', 'PAGE_NOT_FOUND'));
     }
 }
Пример #6
0
<?php

use app\models\Block;
/** @var $id string */
/** @var Block $block */
$block = Block::findOne($id);
if (!is_null($block)) {
    ?>
<div class="block_<?php 
    echo $id;
    ?>
">
    <?php 
    echo $block->getContent(Yii::$app->language);
    ?>
</div>
<?php 
}