public function beforeSave($insert) { if (empty($this->description)) { $this->description = \app\components\Helper::create_descr($this->title, $this->full); } if (empty($this->keywords)) { $this->keywords = \app\components\Helper::create_keywords($this->title, $this->full); } return parent::beforeSave($insert); }
<?php use yii\helpers\Html; use yii\widgets\DetailView; /* @var $this yii\web\View */ /* @var $model app\modules\category\models\Category */ $this->title = 'Комментарий от ' . $model->username; // $this->params['breadcrumbs'][] = ['label' => 'Комментарий', 'url' => ['index']]; $this->params['breadcrumbs'][] = $this->title; $this->registerMetaTag(['name' => 'description', 'content' => \app\components\Helper::create_descr($this->title, $model->post)]); $this->registerMetaTag(['name' => 'keywords', 'content' => \app\components\Helper::create_keywords($this->title, $model->post)]); ?> <div class=""> <h1 class="header"><?php echo Html::encode($this->title); ?> </h1> <?php echo DetailView::widget(['model' => $model, 'attributes' => ['username', ['attribute' => created_at, 'format' => ['date', 'dd.MM.yyyy HH:ss']], 'post']]); ?> </div>