seo = \Yii::$app->get('seo'); $data = []; $this->logoUrl = \Yii::$app->request->hostInfo . '/storage/logo/logo.png'; if ($this->type == 'NewsArticle'){ $data = [ '@context' => "http://schema.org", '@type' => $this->type, "mainEntityOfPage" => [ "@type" => "WebPage", "@id" => \Yii::$app->request->absoluteUrl, ], 'headline' => ( !empty($this->seo->h1) ) ? $this->seo->h1 : $this->model->language->title, 'image' => [ \Yii::$app->request->hostInfo . ImageHelper::set((!empty($this->model->image)) ? $this->model->image->getUrl() : null) ->render(), ], 'datePublished' => date('c', $this->model->created_at), 'dateModified' => date('c', $this->model->updated_at), 'author' => [ '@type' => 'Person', 'name' => 'admin', ], 'publisher' => [ '@type' => 'Organization', 'name' => 'admin', 'logo' => [ '@type' => "ImageObject", 'url' => $this->logoUrl, ], ], 'description' => $this->seo->desc, ]; }elseif ($this->type == 'Organization'){ $data = [ '@context' => 'http://schema.org', "@type"=> $this->type, 'url' => \Yii::$app->request->absoluteUrl, 'logo' => $this->logoUrl, 'contactPoint' => [ "@type" => "ContactPoint", "url" => Url::home(true), "contactType" => "customer service", ] ]; } return $this->render( 'microdata', [ 'data' => Json::encode($data), ] ); } }