public function actionView($slug) { $album = Gallery::cat($slug); if (!$album) { throw new \yii\web\NotFoundHttpException('无照片.'); } // 评论列表 $commentDataProvider = new ActiveDataProvider(['query' => Comment::find()->andWhere(['article_id' => $album->model->category_id, 'parent_id' => 0, 'comment_type' => 'gallery']), 'pagination' => ['pageSize' => 10], 'sort' => ['defaultOrder' => ['id' => SORT_DESC]]]); //评论数 $commentNum = Comment::find()->andWhere(['article_id' => $slug, 'parent_id' => 0, 'comment_type' => 'gallery'])->count(1); $commentModels = $commentDataProvider->getModels(); $pages = $commentDataProvider->getPagination(); // 评论框 $commentModel = new Comment(); return $this->render('view', ['album' => $album, 'photos' => $album->photos(['pagination' => ['pageSize' => 10]]), 'commentModel' => $commentModel, 'commentModels' => $commentModels, 'pages' => $pages, 'commentDataProvider' => $commentDataProvider, 'commentNum' => $commentNum]); }
use common\populac\modules\gallery\api\Gallery; use common\populac\modules\page\api\Page; use yii\helpers\Html; use yii\helpers\Url; $page = Page::get('page-gallery'); $this->title = $page->model->title; $this->params['breadcrumbs'][] = $this->title; ?> <h1><?php echo $this->title; ?> </h1> <br/> <?php foreach (Gallery::cats() as $album) { ?> <a class="center-block" href="<?php echo Url::to(['ji_sheng_feng_cai/view', 'slug' => $album->slug]); ?> "> <?php echo Html::img(Image::thumbFrontend($album->image, 160, 120)); ?> <br/><?php echo $album->title; ?> </a> <br/> <?php }
<?php if (count($photos)) { ?> <div> <h4 class="hidden">照片</h4> <?php foreach ($photos as $photo) { ?> <?php echo $photo->box(100, 100); ?> <?php } ?> <?php Gallery::plugin(); ?> </div> <br/> <?php } else { ?> <p>Album is empty.</p> <?php } echo $album->pages(); echo $this->render('comment', ['model' => $album->model, 'commentModel' => $commentModel, 'commentModels' => $commentModels, 'pages' => $pages, 'commentDataProvider' => $commentDataProvider, 'commentNum' => $commentNum]); echo \common\widgets\danmu\Danmu::widget(['id' => $album->model->category_id, 'comment_type' => 'gallery']); /*$this->registerJsFile('@web/js/jquery.lazyload.min.js', ['depends' => [\yii\web\JqueryAsset::className()]]); $this->registerJs(<<<js $(function(){