예제 #1
0
 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;
 }
예제 #2
0
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);
    ?>
&#8230;&#8230;</p>
        <?php 
} else {
    ?>
        <p><?php 
    echo $row['summary'];
    ?>
&#8230;&#8230;</p>
        <?php 
}
?>
            
        </div>