Commit d8d091fadfb61ed70e2d73be913493423a436ff6
1 parent
0549a813
редактирование микроразметки новости (пока на тест)
Showing
1 changed file
with
59 additions
and
69 deletions
Show diff stats
frontend/views/blog/_article.php
1 | <?php | 1 | <?php |
2 | - | ||
3 | - use artbox\core\helpers\ImageHelper; | ||
4 | - use artbox\core\helpers\Url; | ||
5 | - | ||
6 | - /** | ||
7 | - * @var \common\models\blog\Article $model | ||
8 | - */ | ||
9 | -# значения вынесены, потому что эти данные нужны не только в самой картинке, а и для микроразметки | ||
10 | -$imageWidth=360; | ||
11 | -$imageHeight=240; | ||
12 | -?> | ||
13 | - | ||
14 | - | ||
15 | - | ||
16 | - | ||
17 | - <div class="blog-list-link"><a href="<?=Url::to(['alias' => $model->language->alias])?>"> | ||
18 | - <span><?=$model->body_preview?></span></a></div> | ||
19 | - <?php if (!empty($model->tags)){?> | ||
20 | - <div class="blog-list-tags"> | ||
21 | - <?php foreach ($model->tags as $tag){?> | ||
22 | - <a href="<?=Url::to(['alias' => $tag->language->alias])?>"><?=$tag->title?></a> | ||
23 | - <?php } ?> | ||
24 | - </div> | ||
25 | - <?php } ?> | ||
26 | - | ||
27 | -<div itemtype="http://schema.org/Article" itemscope class="blog-list-wr"> | ||
28 | - <!-- <a itemprop="mainEntityOfPage" href="http://cathscafe.example.com/"><h1 itemprop="name">Cath's Cafe</h1></a>--> | ||
29 | - <a itemprop="mainEntityOfPage" href="<?= Url::to(['blog/index'], true); ?>"><h1 itemprop="name">Cath's Cafe</h1></a> | ||
30 | - <div itemprop="dateModified" content="2015-02-22T14:55:06+00:00">Last Updated: 22 Feb 15</time> | ||
31 | - <div itemscope itemtype="https://schema.org/ImageObject" class="img-blog-list"> | ||
32 | - | ||
33 | - <meta itemprop="url" content="<?=($model->image) ? $model->image->getPath() : null;?>"> | ||
34 | - <meta itemprop="height" content="<?=$imageWidth;?>"/> | ||
35 | - <meta itemprop="width" content="<?=$imageHeight;?>"/> | ||
36 | - | ||
37 | - <a href="<?=Url::to(['alias' => $model->language->alias])?>"> | ||
38 | - <!--360x240--> | ||
39 | - | ||
40 | - | ||
41 | - <?=ImageHelper::set(($model->image) ? $model->image->getPath() : null) | ||
42 | - ->cropResize($imageWidth, $imageHeight) | ||
43 | - ->quality(84) | ||
44 | - ->renderImage(['alt'=>$model->language->attributes['title'],'title'=>$model->language->attributes['title']])?> | ||
45 | - </a> | ||
46 | 2 | ||
3 | +use artbox\core\helpers\ImageHelper; | ||
4 | +use artbox\core\helpers\Url; | ||
47 | 5 | ||
6 | +/** | ||
7 | + * @var \common\models\blog\Article $model | ||
8 | + */ | ||
9 | +# значения вынесены, потому что эти данные нужны не только в самой картинке, а и для микроразметки | ||
10 | +$imageWidth = 360; | ||
11 | +$imageHeight = 240; | ||
12 | +?> | ||
48 | 13 | ||
14 | +<div class="blog-list-wr" itemtype="http://schema.org/Article" itemscope> | ||
15 | + <meta itemprop="datePublished" content="<?= date('d-m-Y', $model->created_at) ?>"/> <!-- ДАТА --> | ||
16 | + <div itemprop="dateModified" content="<?= date('d-m-Y', $model->updated_at) ?>"></div> | ||
17 | + <meta itemprop="mainEntityOfPage" href="<?= Url::to(['blog/index'], true); ?>"></meta> | ||
18 | + <meta itemprop="headline" content="<?= $model->language->title ?>"/> <!-- ХХХ название статьи в H1 --> | ||
19 | + <div class="img-blog-list" itemprop="publisher" itemscope itemtype="https://schema.org/Organization"> | ||
20 | + <div itemprop="logo" itemscope itemtype="https://schema.org/ImageObject"> | ||
21 | + <a href="<?= Url::to(['alias' => $model->language->alias]) ?>"> | ||
22 | + <!--360x240--> | ||
23 | + | ||
24 | + <?php | ||
25 | + $alt = (isset($model->image->lang->attributes['alt'])) ? $model->image->lang->attributes['alt'] : ''; | ||
26 | + $description = (isset($model->image->lang->attributes['description'])) ? $model->image->lang->attributes['description'] : ''; | ||
27 | + | ||
28 | + ?> | ||
29 | + <meta itemprop="url" | ||
30 | + content="http://clinica.loc/storage/helper/17_m3OLnPXP_FqgNDCoOf0zpWi50UHSaOsm_cr_360_x_240_q84.jpg"> | ||
31 | + | ||
32 | + <meta itemprop="height" content="44"/> | ||
33 | + | ||
34 | + <meta itemprop="width" content="54"/> | ||
35 | + <?= ImageHelper::set(($model->image) ? $model->image->getPath() : null) | ||
36 | + ->cropResize(360, 240) | ||
37 | + ->quality(84) | ||
38 | + ->renderImage(['alt' => $alt, 'description' => $description]) ?> | ||
39 | + </a> | ||
40 | + </div> | ||
41 | + <meta itemprop="name" content="<?= Url::home(true); ?>"> | ||
49 | </div> | 42 | </div> |
50 | - | ||
51 | <div class="blog-all-date-views"> | 43 | <div class="blog-all-date-views"> |
52 | - | ||
53 | - <metacontent | ||
54 | - ="<?= date('d-m-Y', $model->created_at); ?>"/> | ||
55 | - <div itemprop="datePublished" class="blog-date"><?= date('d-m-Y', $model->created_at) ?></div> | 44 | + <div class="blog-date"><?= date('d.m.Y', $model->created_at) ?></div> |
56 | <div class="blog-views-comments-ico"> | 45 | <div class="blog-views-comments-ico"> |
57 | - <div class="blog-comments-ico"><?=count($model->comments)?></div> | ||
58 | - <div class="blog-views-ico"><?=$model->views?></div> | 46 | + <div class="blog-comments-ico"><?= count($model->comments) ?></div> |
47 | + <div class="blog-views-ico"><?= $model->views ?></div> | ||
59 | </div> | 48 | </div> |
60 | </div> | 49 | </div> |
50 | + <div class="blog-list-link" itemprop="author" itemscope itemtype="https://schema.org/Person"> | ||
51 | + <a href="<?= Url::to(['alias' => $model->language->alias]) ?>" itemprop="description"> | ||
52 | + <span><?= $model->body_preview ?></span></a> | ||
53 | + <meta itemprop="name" content="<?= Url::home(true); ?>"/> | ||
54 | + </div> | ||
55 | + <?php if (!empty($model->tags)) { ?> | ||
56 | + <div class="blog-list-tags"> | ||
57 | + <?php foreach ($model->tags as $tag) { ?> | ||
58 | + <a href="<?= Url::to(['alias' => $tag->language->alias]) ?>"><?= $tag->title ?></a> | ||
59 | + <?php } ?> | ||
60 | + </div> | ||
61 | + <?php } ?> | ||
62 | + <div itemprop="image" itemscope itemtype="https://schema.org/ImageObject"> | ||
61 | 63 | ||
64 | + <meta itemprop="url" | ||
65 | + content="http://clinica.loc/storage/helper/17_m3OLnPXP_FqgNDCoOf0zpWi50UHSaOsm_cr_360_x_240_q84.jpg"> | ||
62 | 66 | ||
63 | - <meta itemprop="headline" content="XXX"/> <?= $model->title; ?> | ||
64 | - | ||
65 | - <div itemprop="publisher" itemscope itemtype="https://schema.org/Organization"> | 67 | + <meta itemprop="height" content="675"/> |
66 | 68 | ||
69 | + <meta itemprop="width" content="900"/> | ||
70 | + </div> | ||
71 | + </div> | ||
67 | 72 | ||
68 | - <meta itemprop="name" content="<?= \Yii::t('app', 'ABC short'); ?>"> | ||
69 | - <meta itemprop="logo" | ||
70 | - content="<?= 'https://as01.epimg.net/epik/imagenes/2018/03/10/portada/1520705351_010030_1520705450_noticia_normal.jpg'; ?>"> | ||
71 | 73 | ||
72 | - </div> | ||
73 | 74 | ||
74 | - <div itemprop="author" itemscope itemtype="https://schema.org/Person"> | ||
75 | 75 | ||
76 | - <meta itemprop="name" content="<?= Url::home(true) ?>"/> | ||
77 | 76 | ||
78 | - </div> | ||
79 | 77 | ||
80 | - <p itemprop="description"><?= $model->body_preview; ?></p> | ||
81 | 78 | ||
82 | - <div itemprop="image" itemscope itemtype="https://schema.org/ImageObject"> | ||
83 | 79 | ||
84 | - <meta itemprop="url" | ||
85 | - content="<?= 'https://as01.epimg.net/epik/imagenes/2018/03/10/portada/1520705351_010030_1520705450_noticia_normal.jpg'; ?>"> | ||
86 | 80 | ||
87 | - <meta itemprop="height" content="<?= $imageHeight; ?>"/> | ||
88 | 81 | ||
89 | - <meta itemprop="width" content="<?= $imageWidth; ?>"/> | ||
90 | - </div> | ||
91 | -</div> | ||
92 | \ No newline at end of file | 82 | \ No newline at end of file |