This is the community forum. For a developer response use the Client Area.
Follow us on Facebook, Twitter and YouTube!

Microformats: Google Rich Snippets
#1

I wonder if is possible to integrate the commentics stars rating system with Google Rich Snippets Microformats to appear in search results.

Thank you.
Reply
#2

This is totally new to me so I need a bit of time to learn about Rich Snippets first. I assume that the Review markup would be the appropriate type of snippet? Do you want the star ratings to be displayed in an aggregate way, as opposed to individual, so that it gives an overall view of the ratings?


Have you completed the interview?
Reply
#3

Exactly. I am interested in the score can change dynamically.
Reply
#4

This is what I have come up with. I have written it so that the 'page reference' is used as the title. Can you please test the markup for me.

In comments/includes/template/comments.php, find this part:
PHP Code:
<?php 
if ($average_rating != 0) {
echo
$output_average_rating;
echo
"<span class='average_rating_text'>";
echo
" " . CMTX_AVERAGE_RATING;
echo
"</span>";
}

And replace it with this:
PHP Code:
<?php 
if ($average_rating != 0) {
echo
$output_average_rating;
echo
"<span class='average_rating_text'>";
echo
" " . CMTX_AVERAGE_RATING;
echo
"</span>";
//Start of Google 'Rich Snippets' (Microformats markup)
$number_of_ratings = mysql_query("SELECT COUNT(*) FROM `".$mysql_table_prefix."comments` WHERE is_approved = '1' AND rating != '0' AND page_id = '$page_id'");
$r = mysql_fetch_row($number_of_ratings);
$number_of_ratings = $r[0];
echo
"<div class='hreview-aggregate'>";
echo
"<span class='item'>";
echo
"<span class='fn'>" . cmtx_get_page_reference() . "</span>";
echo
"</span>";
echo
"<span class='rating'>";
echo
"<span class='average'>$average_rating</span>";
echo
"<span class='best'>5</span>";
echo
"</span>";
echo
"<span class='votes'>$number_of_ratings</span>";
echo
"<span class='count'>$number_of_comments</span>";
echo
"</div>";
//End of Google 'Rich Snippets'
}

Then add this to your CSS stylesheet:
Code:
.hreview-aggregate {
display: none;
}

Have you completed the interview?
Reply
#5

Wow..!!! You're amazing. Fantastic.
Thanks, Steven.

[Image: richm.jpg]
Reply
#6

I'm glad it worked. Hopefully others will also find it useful.

Have you completed the interview?
Reply
#7

Modified

'commentics_1.6/comments/includes/functions/comments.php'

to show also 'hreview' (not 'aggregate', the single ones) Google 'Rich Snippets' (Microformats markup).

-----------------------------------------------------

Google test tool shows something like this for every comment:

hreview
item fn = Šotori, bungalovi, senčnice, paviljoni, zastave, stojnice - zastopstvo in prodaja.
reviewer hcard
fn = stariocek
rating
value (normalized to 5.0 scale) = 5.0
value = 5
description = komentarji delajo! lp, admin


Attached Files Thumbnail(s)
   
.php comments.php Size: 13.42 KB  Downloads: 39
Reply
#8

Second version of comments.php, now without hidden text for comment - better for SEO.


Attached Files
.php comments.php Size: 13.55 KB  Downloads: 48
Reply
#9

(06-Aug-2011, 11:04 AM)stariocek Wrote:  Second version of comments.php, now without hidden text for comment - better for SEO.

Third version of comments.php, Rich Snippets completely incorporated into initial code. Without ugly tricks for testing purposes.


Attached Files
.php comments.php Size: 13.63 KB  Downloads: 70
Reply
#10

Tried to upload your comments.php and it breaks the page. Sad
Reply


Possibly Related Threads…
Thread / Author Replies Views Last Post
Last Post by philips300
19-May-2024, 11:49 AM
Last Post by Methyus
03-Oct-2016, 01:40 PM
Last Post by Steven
25-Mar-2015, 07:06 PM

Forum Jump:


Users browsing this thread: 2 Guest(s)