_article.php 2.77 KB
<?php
    
    use artbox\core\helpers\ImageHelper;
    use artbox\core\helpers\Url;
    
    /**
     * @var \common\models\blog\Article $model
     */
# значения вынесены, потому что эти данные нужны не только в самой картинке, а и для микроразметки
$imageWidth=360;
$imageHeight=240;
?>




  <div class="blog-list-link"><a href="<?=Url::to(['alias' => $model->language->alias])?>">
          <span><?=$model->body_preview?></span></a></div>
  <?php if (!empty($model->tags)){?>
  <div class="blog-list-tags">
    <?php foreach ($model->tags as $tag){?>
    <a href="<?=Url::to(['alias' => $tag->language->alias])?>"><?=$tag->title?></a>
    <?php } ?>
  </div>
  <?php } ?>


<div itemtype="http://schema.org/Article" itemscope class="blog-list-wr">

    <div itemprop="logo" itemscope itemtype="https://schema.org/ImageObject" class="img-blog-list">

        <meta itemprop="url" content="<?=($model->image) ? $model->image->getPath() : null;?>">
        <meta itemprop="height" content="<?=$imageWidth;?>"/>
        <meta itemprop="width" content="<?=$imageHeight;?>"/>

        <a href="<?=Url::to(['alias' => $model->language->alias])?>">
            <!--360x240-->


            <?=ImageHelper::set(($model->image) ? $model->image->getPath() : null)
                ->cropResize($imageWidth, $imageHeight)
                ->quality(84)
                ->renderImage(['alt'=>$model->language->attributes['title'],'title'=>$model->language->attributes['title']])?>
        </a>



    </div>

    <div class="blog-all-date-views">
	    <?php #die(var_dump($model));  ?>
        <metacontent="<?=date('d.m.Y', $model->created_at);?>"/>
        <div  itemprop="datePublished"  class="blog-date"><?=date('d.m.Y', $model->created_at)?></div>
        <div class="blog-views-comments-ico">
            <div class="blog-comments-ico"><?=count($model->comments)?></div>
            <div class="blog-views-ico"><?=$model->views?></div>
        </div>
    </div>


    <meta itemprop="headline" content="XXX"/> <?= $model->title; ?>

    <div itemprop="publisher" itemscope itemtype="https://schema.org/Organization">


        <meta itemprop="name" content="<?= \Yii::t('app', 'ABC short'); ?>">

    </div>

    <div itemprop="author" itemscope itemtype="https://schema.org/Person">

        <meta itemprop="name" content="<?= Url::home(true) ?>"/>

    </div>

    <p itemprop="description"><?= $model->body_preview; ?></p>

    <div itemprop="image" itemscope itemtype="https://schema.org/ImageObject">

        <meta itemprop="url" content="<?= ($model->image !== null) ? $model->image->getPath() : ''; ?>">

        <meta itemprop="height" content="<?= $imageHeight; ?>"/>

        <meta itemprop="width" content="<?= $imageWidth; ?>"/>
    </div>
</div>