Commit 642cabb944945cdd016199cb02b3e4ff0cee8890
1 parent
4ca4188e
микроразметка тест 6
Showing
1 changed file
with
5 additions
and
3 deletions
Show diff stats
frontend/controllers/BlogController.php
| @@ -5,6 +5,7 @@ | @@ -5,6 +5,7 @@ | ||
| 5 | use common\models\blog\Article; | 5 | use common\models\blog\Article; |
| 6 | use common\models\blog\Category; | 6 | use common\models\blog\Category; |
| 7 | use common\models\blog\Tag; | 7 | use common\models\blog\Tag; |
| 8 | + use frontend\helpers\Url; | ||
| 8 | use yii\data\ActiveDataProvider; | 9 | use yii\data\ActiveDataProvider; |
| 9 | use yii\db\ActiveQuery; | 10 | use yii\db\ActiveQuery; |
| 10 | use yii\helpers\ArrayHelper; | 11 | use yii\helpers\ArrayHelper; |
| @@ -100,7 +101,10 @@ | @@ -100,7 +101,10 @@ | ||
| 100 | "headline" => "Article headline", | 101 | "headline" => "Article headline", |
| 101 | "datePublished" => date('d-m-Y', $model->created_at), | 102 | "datePublished" => date('d-m-Y', $model->created_at), |
| 102 | "dateModified" => date('d-m-Y', $model->created_at), | 103 | "dateModified" => date('d-m-Y', $model->created_at), |
| 103 | - | 104 | + 'image' => [ |
| 105 | + # 'https://google.com/logo.jpg' | ||
| 106 | + ($model->image) ? Yii::$app->request->hostInfo . $model->image->getPath() : 'https://google.com/logo.jpg' | ||
| 107 | + ], | ||
| 104 | 108 | ||
| 105 | "author" => [ | 109 | "author" => [ |
| 106 | "@type" => "Person", | 110 | "@type" => "Person", |
| @@ -118,8 +122,6 @@ | @@ -118,8 +122,6 @@ | ||
| 118 | ] | 122 | ] |
| 119 | ]; | 123 | ]; |
| 120 | 124 | ||
| 121 | - if ($model->image) $resultMicrodata['image'] = $model->image->getPath(); | ||
| 122 | - | ||
| 123 | 125 | ||
| 124 | $resultMicrodata = new MicrodataFabric(); | 126 | $resultMicrodata = new MicrodataFabric(); |
| 125 | $resultMicrodata = $resultMicrodata::createJsonFromArticle($jsonLdMicrodata)->toJson(); | 127 | $resultMicrodata = $resultMicrodata::createJsonFromArticle($jsonLdMicrodata)->toJson(); |