首页 > 解决方案 > 我应该使用 PHP 来实现 Schema.org 综合评分吗?

问题描述

无法处理 Schema.org 综合评级的实施。

我的代码:

<div id="page-rating">
    <form id="rating-form">
        <input type="hidden" name="_token" value="myToken">
        <input type="hidden" name="page" value="11">
        <input type="hidden" name="a" value="review">
        <span class="rating-star">
            <input type="radio" name="rating" value="5">
            <span class="star"></span>
            <input type="radio" name="rating" value="4">
            <span class="star"></span>
            <input type="radio" name="rating" value="3">
            <span class="star"></span>
            <input type="radio" name="rating" value="2">
            <span class="star"></span>
            <input type="radio" name="rating" value="1">
            <span class="star"></span>
        </span>
    </form>
        <div id="rating-text">Rating: <span id="rating-value">5.00</span> from 5. Count of votes: <span id="rating-count">9</span> users</div>
</div>

脚本:

<script type="application/ld+json">
{
  "@context": "http://schema.org/", 
  "@type": "Product", 
  "name": "Some Product",
  "image": "path/to/image.png",
  "description": "Some Description",
  "brand": "Some Brand name",
  "offers": {
    "@type": "AggregateOffer",
    "priceCurrency": "BGN",
    "lowPrice": "150.00",
    "offerCount": 9
  },
    "aggregateRating": {
        "@type": "AggregateRating",
        "ratingValue": "5.00",
        "reviewCount": "8"
    }
}
</script>

好的,现在我不知道更新时要做什么?如果有人点击?

我认为必须发生的事情是在点击 .php 文件时发送 AJAX 并将新记录添加到一些数据库表(mysql)。然后在页面加载时通过 ajax 再次调用 .php 文件并获取评分 + 票数并更新 json 和 div 中的值。我对吗 ?

标签: javascriptphphtmlschema.org

解决方案


推荐阅读