Keyword

Rating Schema Snippet for K2 Articles

  • Mr_Anonymous
  • Mr_Anonymous's Avatar Topic Author
  • Offline
  • Premium Member
More
10 years 8 months ago - 10 years 8 months ago #131146 by Mr_Anonymous
Rating Schema Snippet for K2 Articles was created by Mr_Anonymous
I understand that rating schema can be added to K2 by editing the sub-template. Has anyone added the rating schema for K2's star rating? Would you mind sharing your snippet of code you used inside the itemRatingBlock to add the schema please? I am new to schemas and I not sure how to add the rating schema to k2 articles. So any help will be so much helpful please :)

Please Log in or Create an account to join the conversation.

  • Krikor Boghossian
  • Krikor Boghossian's Avatar
  • Offline
  • Platinum Member
More
10 years 8 months ago #131147 by Krikor Boghossian
Replied by Krikor Boghossian on topic Re: Rating Schema Snippet for K2 Articles
At this point I can only point you to documentation since I personally have not implemented it.

This is the documentation for the schema.
schema.org/Rating

The documentation for overriding item.php
getk2.org/documentation/tutorials/174-templating-with-k2-and-the-concepts-of-sub-templates

JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)

Please Log in or Create an account to join the conversation.

  • Mr_Anonymous
  • Mr_Anonymous's Avatar Topic Author
  • Offline
  • Premium Member
More
10 years 8 months ago #131148 by Mr_Anonymous
Replied by Mr_Anonymous on topic Re: Rating Schema Snippet for K2 Articles
Thanks Krikor for the links. I am used to overriding k2 template and thats pretty easy. However, its only adding schema to k2's rating section I am not sure about. Your link was helpful (i read that last night). Anyhow, I will try to add what I've learnt to the k2 rating and will post it back (probably sometime this week). Hopefully someone can have a look and check if what I have done is right. :)

Please Log in or Create an account to join the conversation.

  • Krikor Boghossian
  • Krikor Boghossian's Avatar
  • Offline
  • Platinum Member
More
10 years 8 months ago #131149 by Krikor Boghossian
Replied by Krikor Boghossian on topic Re: Rating Schema Snippet for K2 Articles
You can share your code here for knowledge purposes.

JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)

Please Log in or Create an account to join the conversation.

  • Mr_Anonymous
  • Mr_Anonymous's Avatar Topic Author
  • Offline
  • Premium Member
More
10 years 8 months ago #131150 by Mr_Anonymous
Replied by Mr_Anonymous on topic Re: Rating Schema Snippet for K2 Articles
Hi Krikor,

Here is my incomplete attempt on adding schema to K2 item. I am trying to implement AggregateRating something like this:
Log in  or Create an account to join the conversation.

  • Krikor Boghossian
  • Krikor Boghossian's Avatar
  • Offline
  • Platinum Member
More
10 years 8 months ago #131151 by Krikor Boghossian
Replied by Krikor Boghossian on topic Re: Rating Schema Snippet for K2 Articles
1) It seems correct. You should build upon the correct rating. As for schemas I am not really the expert.

2) <?php echo $this->item->votingPercentage; ?> Will give you the voting percentage.

3) You should use str_replace() for this one.

JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)

Please Log in or Create an account to join the conversation.

  • Mr_Anonymous
  • Mr_Anonymous's Avatar Topic Author
  • Offline
  • Premium Member
More
10 years 8 months ago #131152 by Mr_Anonymous
Replied by Mr_Anonymous on topic Re: Rating Schema Snippet for K2 Articles
Thats perfect. Thank you so much. You have helped a lot. I will add those and will post it back once I've done it. :)

Please Log in or Create an account to join the conversation.

  • Mr_Anonymous
  • Mr_Anonymous's Avatar Topic Author
  • Offline
  • Premium Member
More
10 years 8 months ago - 10 years 7 months ago #131153 by Mr_Anonymous
Replied by Mr_Anonymous on topic Re: Rating Schema Snippet for K2 Articles
Hi Krikor,

This is what I've done to add the AggregateRating schema to k2's star rating:
Log in  or Create an account to join the conversation.

More
10 years 7 months ago #131154 by Arnold Wender
Replied by Arnold Wender on topic Re: Rating Schema Snippet for K2 Articles
Hello,

Did you figured out how to show only the number of votes, without the language string?

This is how it looks right now on my template:

Attachment not found



Cheers
Attachments:

Please Log in or Create an account to join the conversation.

  • Mr_Anonymous
  • Mr_Anonymous's Avatar Topic Author
  • Offline
  • Premium Member
More
10 years 7 months ago #131155 by Mr_Anonymous
Replied by Mr_Anonymous on topic Re: Rating Schema Snippet for K2 Articles
Yeah I did.. Have a look at the last meta line here . I've used str_replace() to remove the strings and show only numbers like this:
Log in  or Create an account to join the conversation.

More
10 years 7 months ago #131156 by Arnold Wender
Replied by Arnold Wender on topic Re: Rating Schema Snippet for K2 Articles
I have exactly the same code but if you check with an extension like Semantic inspector:

goo.gl/35SwuP

You will see that ratingCount adds:

1Vote

in German:

1Stimme

Instead of just the number...

Cheers

Arnold

Please Log in or Create an account to join the conversation.

  • Mr_Anonymous
  • Mr_Anonymous's Avatar Topic Author
  • Offline
  • Premium Member
More
10 years 7 months ago #131157 by Mr_Anonymous
Replied by Mr_Anonymous on topic Re: Rating Schema Snippet for K2 Articles
Not sure. Maybe the words 'Vote' and 'Stimme' are automatically added by google after the number? In that case, perhaps it might be useful to add a space after the voting count number in the meta tag.

Please Log in or Create an account to join the conversation.

More
10 years 4 months ago #135412 by Seekat Seemonster
Replied by Seekat Seemonster on topic Re: Rating Schema Snippet for K2 Articles
Hi there

Thanks for the valuable input on star rating and rich snippets. I'm trying to do more or less what's being describe in your article. The only difference is, I would like to use K2's build-in star rating. I'm also very new to the coding used to call data from an item. I gathered that last bit of your coding would be to recall the data gathered and output it in rich snippet form.
- <div id="itemRatingLog<?php echo $this->item->id; ?>" class="itemRatingLog"> <?php echo $this->item->numOfvotes; ?> </div>
<!-- Section for Schema -->
<meta itemprop="bestRating" content="5">
<meta itemprop="ratingValue" content="<?php echo ($this->item->votingPercentage / 20); ?>">
<meta itemprop="ratingCount" content="<?php echo (str_replace(array('(', ')', 'Vote', ' '), '', $this->item->numOfvotes)); ?>">


What bits of code would I need to change to recall the star rating data already embedded in the item?

Also still struggling with JCE stripping bits of code like - ?php echo $this->item->id; ?
As well as <meta itemprop="bestRating" content="5"> which I have to change to the following for JCE not to strip <span itemprop="bestRating" content="5"></span>



Please Log in or Create an account to join the conversation.

  • Mr_Anonymous
  • Mr_Anonymous's Avatar Topic Author
  • Offline
  • Premium Member
More
10 years 4 months ago #135418 by Mr_Anonymous
Replied by Mr_Anonymous on topic Rating Schema Snippet for K2 Articles
I havent tried adding microdata through JCE or other editors. I find its easier to add the microdata to the php files directly using Template override. That way I dont need to worry about editors stripping codes, etc...

Please Log in or Create an account to join the conversation.

  • Krikor Boghossian
  • Krikor Boghossian's Avatar
  • Offline
  • Platinum Member
More
10 years 4 months ago #135453 by Krikor Boghossian
Replied by Krikor Boghossian on topic Rating Schema Snippet for K2 Articles
I concur with Mr_Anonymous. The best way to achieve this is through template overrides.

JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)

Please Log in or Create an account to join the conversation.