public function saveContent($model, $bodyModel) { $postDatas = Yii::$app->request->post(); if ($model->load($postDatas) && $bodyModel->load($postDatas) && $model->validate() && $bodyModel->validate()) { if ($model->summary === null || $model->summary === '') { if ($bodyModel->hasAttribute('body')) { $content = strip_tags($bodyModel->body); $pattern = '/\\s/'; // 去除空白 $content = preg_replace($pattern, '', $content); $model->summary = StringHelper::subString($content, 250); } } if ($model->save()) { $bodyModel->content_id = $model->id; $bodyModel->save(); return $this->redirect(['index']); } } return false; }
echo $row['view_count']; ?> ° </span> <!-- .entry-meta --> </div> <!-- .entry-header --> </header> <div class="clearfix entry-content"> <div class="article-summary"> <?php if (!empty($row['thumb'])) { ?> <p><?php echo StringHelper::subString($row['summary'], 90); ?> ……</p> <?php } else { ?> <p><?php echo $row['summary']; ?> ……</p> <?php } ?> </div>