index.php 2.54 KB
<?php
    use common\modules\comment\assets\CommentAsset;
use frontend\widgets\Seo;
use yii\helpers\Html;
    use yii\helpers\Url;
    use yii\widgets\Breadcrumbs;
    //use app\models\News;
    use yii\widgets\LinkPager;
    use frontend\components\Text;
    Yii::$app->getModule('artbox-comment');
    CommentAsset::register($this);
?>
<?php
    $this->title = 'Статьи';

    $this->params[ 'seo' ][ Seo::H1] =  $this->title ;
    $this->params[ 'seo' ][ Seo::TITLE] = $this->title;

    $this->params['breadcrumbs'][] = $this->title;

    $this->registerMetaTag([
        'name'    => 'description',
        'content' => 'Статьи',
    ]);
    $this->registerMetaTag([
        'name'    => 'keywords',
        'content' => 'Статьи',
    ]);
?>

    
<div class="container">
    <h1>Блог</h1>

    <?php foreach($news as $item): ?>
        <div class="news_item">
            <a href="<?= Url::to([
                'articles/show',
                'translit' => $item->translit,
            ]) ?>">
                <?= Html::img(\common\components\artboximage\ArtboxImageHelper::getImageSrc($item->imageUrl, 'list'), [ 'class' => 'float-left' ]) ?>
            </a>
            <a href="<?= Url::to([
                'articles/show',
                'translit' => $item->translit,
            ]) ?>" class="name"><?= $item->title ?></a><br/>
            <div class="comment_display_block article_list_comment">
                <?php
                    if(!empty( $item->averageRating && $item->averageRating->value > 0 )) {
                        ?>
                        <div class="rateit" data-rateit-value="<?php echo $item->averageRating->value; ?>" data-rateit-readonly="true" data-rateit-ispreset="true"></div>
                        <?php
                    }
                ?>
                <p>
                    <?php
                        $comment_count = count($item->comments);
                        echo Html::a(( $comment_count ? 'Отзывов: ' . count($item->comments) : "Оставить отзыв" ), [
                            'articles/show',
                            'translit' => $item->translit,
                            '#'        => 'artbox-comment',
                        ]);
                    ?>
                </p>
            </div>
            <?= Text::getShort($item->body, 600); ?>
            <div class="both"></div>
        </div>
    <?php endforeach; ?>

    <div class="both"></div>
    <?= LinkPager::widget([
        'pagination'       => $pages,
        'registerLinkTags' => true,
    ]); ?>

</div>