コード例 #1
0
 public function actionView($slug)
 {
     $news = News::get($slug);
     if (!$news) {
         throw new \yii\web\NotFoundHttpException('News not found.');
     }
     //return $this->render('view', [
     //    'news' => $news
     //]);
     return $this->render('index', ['news' => News::items(['pagination' => ['pageSize' => 5]]), 'currentNews' => $news]);
 }
コード例 #2
0
ファイル: news.php プロジェクト: egor-pisarev/merro
?>
                    <?php 
echo Html::a('[Подробно]', ['site/news', 'slug' => $lastNews->slug], ['class' => 'more-link']);
?>
                </p>
            </div>
        </div>
    </div>
</div>

<div class="container">
    <div class="row">
        <div class="col col-9 news-content news-block">
            <h2>Свежие новости</h2>
            <?php 
foreach (News::items() as $newsItem) {
    ?>
                <div>
                    <?php 
    echo Html::a($newsItem->title, ['site/news', 'slug' => $newsItem->slug]);
    ?>
                    <small>[<?php 
    echo date('Y-m-d', $newsItem->time);
    ?>
]</small>
                </div>


            <?php 
}
?>
コード例 #3
0
ファイル: NewsController.php プロジェクト: MaoCzedun/AdCoin
 public function actionIndex($tag = null)
 {
     return $this->render('index', ['news' => News::items(['tags' => $tag, 'pagination' => ['pageSize' => 2]])]);
 }