Ratings, like those that Fivestar provides, are some of the itemtypes that the search engines pull into search results.

Fivestar can integrate with the microdata module to provide an interface for mapping Fivestar to microdata itemtypes and itemprops. It should provide a default mapping that uses schema.org, but allow users to make up their own mappings as well.

CommentFileSizeAuthor
#1 1285084_microdata.patch5.02 KBlinclark

Comments

Anonymous’s picture

Status: Active » Needs review
StatusFileSize
new5.02 KB

Ok, so this patch should kind of work.

To test it:

  1. Enable microdata module
  2. Create a Product content type
  3. In microdata settings for the content type, enter itemtype: http://schema.org/Product, title itemprop: name
  4. Add a rating field. Be sure to use the Stars (rated while editing) widget, the patch doesn't yet work with the other widgets
  5. On the field config form, under "Default Microdata Mappings", select schema.org and click Use Default Mapping. This should fill in the fields with the defaults.
  6. Save the content type
  7. Create a new piece of content and rate it
  8. Paste the following in the body field (Rich Snippets need a certain amount of related data before they display)
      <div itemprop="offers" itemscope itemtype="http://schema.org/Offer">
        <span itemprop="price">$55.00</span>
        <link itemprop="availability" href="http://schema.org/InStock" />In stock
      </div>
    
      Product description:
      <span itemprop="description">0.7 cubic feet countertop microwave.
      Has six preset cooking categories and convenience features like
      Add-A-Minute and Child Lock.</span>
    
      Customer reviews:
    
      <div itemprop="reviews" itemscope itemtype="http://schema.org/Review">
        <span itemprop="name">Not a happy camper</span> -
        <span itemprop="description">The lamp burned out and now I have to replace
        it. </span>
      </div>
    
      <div itemprop="reviews" itemscope itemtype="http://schema.org/Review">
        <span itemprop="name">Value purchase</span> -
        <span itemprop="description">Great microwave for the price. It is small and
        fits in my apartment.</span>
      </div>
    
  9. Test the output at http://www.google.com/webmasters/tools/richsnippets ... it should show stars
ericduran’s picture

Tagging, I'll review this later.

silkogelman’s picture

Applied the patch and it works exactly as Lin described.
The star info shows up in the Rich Snippets Testing Tool, really cool stuff!

Extracted rich snippet data from the page:
Item
Type: http://schema.org/product
name = Drupal Product
aggregaterating = Item( 1 )
Item 1
Type: http://schema.org/aggregaterating
ratingvalue = 5

Anonymous’s picture

Great, thanks for testing! If you have any suggestions for how something could work better, let me know.

Eric, if you want to give a look at the code and see if the way it works makes sense, that would be really helpful... I'm trying to make sure there aren't any DX WTFs.

ericduran’s picture

Status: Needs review » Fixed

@linclark You're awesome. I had to make some small changes being that it threw some exceptions but nothing major.

This is great.

I also gave you proper commit credit ;-)

This is now fixed. -- http://drupalcode.org/project/fivestar.git/commit/97a1f60

We probably need a follow up issue about getting it working with the "edit while viewing" but we'll just follow up on that some other time.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

Michsk’s picture

Has this also maybe been backported to D6?

remkovdz’s picture

Is this already incorporated in the Microdata module? I'm asking because I downloaded it and follow the instructions on #1, but no result? Thanks.

Gastonia’s picture

Status: Closed (fixed) » Active

Wanted to check in about comment #5. Indeed we'd like to use 'edit while viewing.' In fact, we are following this tutorial here verbatim to allow each commenter to add a comment and rate at the same time.

http://drupal.org/node/1308114

Here is a test site that followed the above tutorial
http://food.hokkaido-select.com/node/1

If you check out the source code you'll notice that no microdata exists for the aggregated average or for the individual comment items.

Am I doing something wrong or has this just not been implmented yet? Should I open another issue?

Thanks!

Gastonia’s picture

Just like in #8, I too have followed the directions. But I can't get this to work or show up in the markup at all. Has the patch been committed or do we need to do this even now?

whiteph’s picture

Issue summary: View changes
whiteph’s picture

Status: Active » Postponed (maintainer needs more info)
whiteph’s picture

Status: Postponed (maintainer needs more info) » Closed (won't fix)