== function onStart() { // This render is cached, so we cannot add to the graph // We will print our schema separately and reference the graph // Skip in the backend (plugin renders the partials to grab content for search but there is no frontend controller) if (app()->runningInBackend()) return; $seo = \App::make('dynamedia.posts.seo'); $seo->loadProperties($this->controller); $templateData = $this['template']; $review = \Spatie\SchemaOrg\Schema::review() ->setProperty("@id", $this['post']->url . "#productReview") ->setProperty('mainEntityOfPage', ["@id" => $seo->getSchemaArticleId()]) ->setProperty('isPartOf', ["@id" => $seo->getSchemaArticleId()]) ->setProperty('author', ["@id" => $seo->getSchemaAuthorId()]); $product = \Spatie\SchemaOrg\Schema::product() ->setProperty("@id", $this['post']->url . "#reviewedProduct") ->setProperty('review', ["@id" => $this['post']->url . "#productReview"]) ->name($templateData['product_name']) ->description($templateData['product_description']) ->sameAs($templateData['product_info_url']); if (!empty($templateData['product_images'][0]['image'])) { $productImage = \Spatie\SchemaOrg\Schema::imageObject() ->url(\Cms\Classes\MediaLibrary::url($templateData['product_images'][0]['image'])); $product->image($productImage); } $rating = \Spatie\SchemaOrg\Schema::rating() ->ratingValue($templateData['product_rating']); $review->itemReviewed($product) ->reviewRating($rating); $this['schema_script'] = $review->toScript(); } == {{ schema_script | raw }}

{{ 'postbody_template.product_review.title.where_to_buy' | _ }}: {{ template.product_buy_store }}

{{ 'postbody_template.product_review.title.product_score' | _ }}: {% for i in range(1, 5) %} {% endfor %}

{{ template.product_intro | raw }}
{{ template.product_review_body | raw }}

{{ 'postbody_template.product_review.title.images' | _ }}

{% for item in template.product_images %}
item.alt_text {% if item.caption %}
{{ item.caption }}
{% endif %}
{% endfor %}

{{ 'postbody_template.product_review.title.positives' | _ }}

{{ 'postbody_template.product_review.title.negatives' | _ }}

{{ 'postbody_template.product_review.title.verdict' | _ }}

{{ template.product_verdict | raw }}
{% if template.product_rating >= 4 %}
{{ 'postbody_template.product_review.title.buy_link' | _ ({ product: template.product_name }) }}
{% endif %}