在我的评论加价MVC中,我应在哪里包括AggregateRating

时间:2019-04-03 09:14:10

标签: html model-view-controller semantic-markup

当我通过Google结构化数据测试工具放置产品页面源代码时,由于没有AggregateRating而出现错误。

我尝试在标记中加入AggregateRating,包装了我的评分值,但仍然出现以下错误-多个评论应附有总计评分。

<div class="row">
    <div class="col-xs-12">
        @if (Model.Reviews.Count > 0)
        {
            <div class="reviews">
                @Html.Partial("_FeefoProductRating", Model)
                <h2>Selected reviews</h2>
                <div itemscope itemtype="http://schema.org/Organization">
                    <div class="hidden" itemprop="aggregateRating" itemscope itemtype="http://schema.org/AggregateRating">
                        <div>
                            <span itemprop="ratingValue">@(Model.StarRating / 5 * 100)</span> based on <span itemprop="ratingCount">@Model.Reviews.Count</span> ratings
                            <span itemprop="bestRating">100</span>
                            <span itemprop="worstRating">0</span>
                            <span itemprop="ratingCount">@Model.Reviews.Count()</span>
                        </div>
                    </div>
                </div>
                @foreach (var review in Model.Reviews)
                {
                    <div class="user-review review-@review.Rating clearfix" itemprop="review" itemscope itemtype="http://schema.org/Review">
                        <div class="user-review__rating ninja" itemprop="reviewRating" itemscope itemtype="http://schema.org/Rating">
                            <span itemprop="worstRating" content="1"></span>
                            <span itemprop="bestRating">5</span>
                            <span class="user-review__rating-value" itemprop="ratingValue">@review.Rating</span>                            
                        </div>
                        <div class="user-review__source ninja" itemprop="name">@Cortana.Core.Properties.Settings.Default.GlobalSiteName</div>
                        <div class="user-review__stars"></div>
                        <div class="user-review__date" itemprop="datePublished" content="@review.DateCreated.ToString("yyyy-MM-dd")">
                            @Cortana.Core.Extension.ToHumanDate(review.DateCreated)
                        </div>
                        <div class="user-review__description" itemprop="description">
                            <p>@Html.Raw(review.UserReview)</p>
                        </div>
                        <div class="user-review__meta" itemprop="author">
                            @(!String.IsNullOrEmpty(review.DisplayName) ? review.DisplayName : "Anonymous customer")
                        </div>
                    </div>
                }

                @if (!string.IsNullOrEmpty(feefoProductReviewLink))
                {
                    <div class="reviews__footer">
                        <a href="https://ww2.feefo.com/en-gb/reviews/surface-2-air-sports" target="_blank">View all reviews here</a>
                    </div>
                }

            </div>
        }
        else
        {
            <div class="reviews reviews--empty">
                <div class="feefo"></div>
                <p>No product reviews yet.</p>
            </div>
        }
    </div>
</div>

页面资源标记

<div class="user-review review-5 clearfix" itemprop="review" itemscope itemtype="http://schema.org/Review">
    <div class="user-review__rating ninja" itemprop="reviewRating" itemscope itemtype="http://schema.org/Rating"><span itemprop="worstRating" content="1"></span><span itemprop="bestRating">5</span><span class="user-review__rating-value" itemprop="ratingValue">5</span></div>
    <div class="user-review__source ninja" itemprop="name">Surface 2 Air Sports</div>
    <div class="user-review__stars"></div>
    <div class="user-review__date" itemprop="datePublished" content="2018-06-10"> Sunday 10th June 2018 </div>
    <div class="user-review__description" itemprop="description">
        <p>Service rating : Awesome as always!!!
            <br />Friendly
            <br />Knowledgable
            <br />Product : Fantastic thanks,great products great prices and always excellent stock</p>
    </div>
    <div class="user-review__meta" itemprop="author"> Anonymous customer </div>
</div>

用于返回传递AggregateRating的Google结构化数据工具。

谢谢您的帮助!

0 个答案:

没有答案