seo.php
1.74 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
<?php
use yii\helpers\Html;
use frontend\themes\defaults\assets\AppAsset;
/**
* @var $model \frontend\modules\news\models\Article
* @var $params \thread\modules\sys\modules\configs\components\ConfigsParams
* @var $meta \thread\modules\seo\components\MetaTag
* @var $metaBaseInfo \thread\modules\seo\modules\info\components\MetaBaseInfo
*/
$bundle = AppAsset::register($this);
$meta = Yii::$app->metatag;
$metaBaseInfo = Yii::$app->metabaseinfo;
//
$image = $metaBaseInfo->getBaseUrl() . '/' . $model->getImageLink();
$imagePath = $model->getImagePath();
$link = $model->getUrl();
if ($image === null) {
$image = $metaBaseInfo->getBaseUrl() . '/images/blog-1.jpg';
$image = $imagePath;
}
list($width, $height, $type, $attr) = getimagesize($image);
//
$meta->set_image_url($image);
$metaBaseInfoLogo = $metaBaseInfo->getSiteLogo();
try {
list($widthl, $heightl, $typel, $attrl) = getimagesize($metaBaseInfoLogo);
} catch (Exception $exception) {
}
?>
{
"@context": "http://schema.org",
"@type": "NewsArticle",
"mainEntityOfPage": {
"@type": "WebPage",
"@id": "https://google.com/article"
},
"headline": "<?= Html::encode($model['lang']['title']) ?>",
"image": {
"@type": "ImageObject",
"url": "<?= $image ?>",
"height": "<?= $height??0 ?>",
"width": "<?= $width??0 ?>"
},
"datePublished": "<?= $model->getPublishedTimeISO() ?>",
"dateModified": "<?= $model->getModifiedTimeISO() ?>",
"author": {
"@type": "Person",
"name": "<?= $params->getByName('shop_name') ?>"
},
"publisher": {
"@type": "Organization",
"name": "<?= $params->getByName('shop_name') ?>",
"logo": {
"@type": "ImageObject",
"width": "<?= $widthl??0 ?>",
"height": "<?= $heightl??0 ?>",
"url": "<?= $metaBaseInfoLogo ?>"
}
},
"description": "<?= Html::encode($model['lang']['description']) ?>"
}