diff --git a/frontend/controllers/NewController.php b/frontend/controllers/NewController.php
deleted file mode 100644
index 5373264..0000000
--- a/frontend/controllers/NewController.php
+++ /dev/null
@@ -1,22 +0,0 @@
-toJson());
- die;
- }
-}
\ No newline at end of file
diff --git a/frontend/controllers/ServiceController.php b/frontend/controllers/ServiceController.php
index ecae167..5d2b93e 100644
--- a/frontend/controllers/ServiceController.php
+++ b/frontend/controllers/ServiceController.php
@@ -31,6 +31,7 @@
}
+ # список цен для микроданных
$prices=[];
foreach ($model->prices as $kry=>$price)
{
@@ -56,21 +57,11 @@
:[
'type'=>'Product',
'name'=> "'{$model->language->attributes['title']}'",
- 'image'=> [
- 'https://example.com/photos/1x1/photo.jpg',
- 'https://example.com/photos/4x3/photo.jpg',
- 'https://example.com/photos/16x9/photo.jpg'
- ],
'offers'=> [
'@type'=> 'Offer',
'priceCurrency'=> 'UAH',
'Price'=> "'".max($prices)."'",
- 'priceValidUntil'=> '2020-11-05',
- 'itemCondition'=> 'http://schema.org/UsedCondition',
- 'availability'=> 'http://schema.org/InStock',
- 'seller'=> [
- 'type'=> 'Organization',
- 'name'=>'Executive Objects']
+
]
];
diff --git a/frontend/microdata/ArticleMicrodata.php b/frontend/microdata/ArticleMicrodata.php
index d357ed6..05f7b11 100644
--- a/frontend/microdata/ArticleMicrodata.php
+++ b/frontend/microdata/ArticleMicrodata.php
@@ -20,15 +20,9 @@ class ArticleMicrodata extends Microdata
# обрезаю входящие свойства, работаем только с реально существующими
foreach ($config as $key=>$value){
if(!property_exists(self::class,$key))
- {
unset($config[$key]);
- }
elseif($value==null || $value===false || $value=='')
- {
unset($config[$key]);
- }
-
-
}
@@ -37,13 +31,6 @@ class ArticleMicrodata extends Microdata
parent::__construct($config);
}
-
- public function createJson()
- {
-
- }
-
-
public function toJson(): string
{
$resultJson="
-
-
-
-
-
-
-
-
-
-
- */
-
}
diff --git a/frontend/microdata/Microdata.php b/frontend/microdata/Microdata.php
index 7c7b421..ae834f7 100644
--- a/frontend/microdata/Microdata.php
+++ b/frontend/microdata/Microdata.php
@@ -13,7 +13,6 @@ class Microdata extends BaseObject
public $name=null;
public $type=null;
public $image=null;
- public $test=null;
public $offers=null;
}
\ No newline at end of file
diff --git a/frontend/microdata/ProductMicrodata.php b/frontend/microdata/ProductMicrodata.php
index 643332b..4aecbad 100644
--- a/frontend/microdata/ProductMicrodata.php
+++ b/frontend/microdata/ProductMicrodata.php
@@ -7,9 +7,7 @@ use yii\base\BaseObject;
class ProductMicrodata extends Microdata
{
- public $type=null;
- public $name=null;
- public $image=null;
+
public $brand=null;
public $aggregateRating=null;
public $offers=null;
@@ -45,32 +43,27 @@ class ProductMicrodata extends Microdata
parent::__construct($config);
}
-
- public function createJson()
- {
-
- }
-
-
public function toJson(): string
{
$resultJson=" ';
+
return $resultJson;
}
+
function add($key,$value)
{
if ($value!==null)
@@ -79,81 +72,6 @@ class ProductMicrodata extends Microdata
}
- public function test()
- {
-
-
- #Для страниц услуг где представлена только одна цена
- $productArray=[
- 'type'=>'Product',
- 'name'=> 'Executive Anvil',
- 'image'=> [
- 'https://example.com/photos/1x1/photo.jpg',
- 'https://example.com/photos/4x3/photo.jpg',
- 'https://example.com/photos/16x9/photo.jpg'
- ],
- 'description'=>'Sleeker than ACME\'s Classic Anvil, the Executive Anvil is perfect for the business traveler looking for something to drop from a height.',
- 'mpn'=>'925872',
- 'brand'=>[
- 'type'=> 'Thing',
- 'name'=> 'ACME'
- ],
- 'aggregateRating'=>
- [
- 'type'=> 'AggregateRating',
- 'ratingValue'=> '4.4',
- 'reviewCount'=> '89'
- ],
- 'offers'=> [
- '@type'=> 'Offer',
- 'priceCurrency'=> 'USD',
- 'Price'=> '199.99',
- 'priceValidUntil'=> '2020-11-05',
- 'itemCondition'=> 'http://schema.org/UsedCondition',
- 'availability'=> 'http://schema.org/InStock',
- 'seller'=> [
- 'type'=> 'Organization',
- 'name'=>'Executive Objects']
- ]
- ];
-
-
- #Для страниц услуг где представлены 2 и больше цен
- $layout2=
- [
- '@context'=> 'http://schema.org/',
- '@type'=> 'Product',
- 'name'=> 'Executive Anvil',
- 'image'=>
- [
- 'https://example.com/photos/1x1/photo.jpg',
- 'https://example.com/photos/4x3/photo.jpg',
- 'https://example.com/photos/16x9/photo.jpg'
- ],
- 'brand'=>
- [
- '@type'=> 'Thing',
- 'name'=> 'ACME'
- ],
- 'aggregateRating'=>
- [
- '@type'=> 'AggregateRating',
- 'ratingValue'=> '4.4',
- 'ratingCount'=> '89'
- ],
- 'offers' =>
- [
- '@type'=> 'AggregateOffer',
- 'lowPrice'=> '119.99',
- 'highPrice'=> '199.99',
- 'priceCurrency'=> 'USD'
- ]
- ];
-
-
- }
-
-
diff --git a/frontend/microdata/settings/settings.php b/frontend/microdata/settings/settings.php
index 829fcd0..6cb193b 100644
--- a/frontend/microdata/settings/settings.php
+++ b/frontend/microdata/settings/settings.php
@@ -4,4 +4,5 @@
return [
'`context'=>"http://schema.org",
+
];
\ No newline at end of file
diff --git a/frontend/views/layouts/main.php b/frontend/views/layouts/main.php
index fcd6d19..cd7bd1b 100755
--- a/frontend/views/layouts/main.php
+++ b/frontend/views/layouts/main.php
@@ -55,15 +55,64 @@
]
)->orderBy('sort')
->all();
-
- $this->registerMetaTag(
- [
- 'name' => 'description',
- 'content' => $seo->desc,
- ]
- );
-
-
+
+
+
+//-----------------------------------------------------------------------------------------------------------------------
+// Блок с микроразметкой для FB
+
+ # $property нужно для property="og:type" FB
+ switch (\Yii::$app->controller->id)
+ {
+ case "site":
+ $property='website';
+ break;
+ case "blog":
+ $property='article';
+ break;
+ case 'service':
+ $property='product';
+ break;
+ default:
+ $property='website';
+ break;
+ }
+
+$this->registerMetaTag(
+ [
+ 'property'=>'og:description',
+ 'content' => $seo->desc,
+ ]
+);
+$this->registerMetaTag(
+ [
+ 'property'=>"og:type",
+ 'content' => $property,
+ ]
+);
+$this->registerMetaTag(
+ [
+ 'property'=>"og:url",
+ 'content' => Url::current(),
+ ]
+);
+$this->registerMetaTag(
+ [
+ 'property'=>"og:title",
+ 'content' =>$seo->title,
+ ]
+);
+$this->registerMetaTag(
+ [
+ 'name' => 'description',
+ 'property'=>"og:image",
+ 'content' => \Yii::$app->homeUrl."/storage/logo/".$settings->logo,
+ ]
+);
+
+//----------------------------------------------------------------------------------------------------------------------
+
+
$this->registerMetaTag(
[
'name' => 'robots',
--
libgit2 0.21.4