COMMUNITY FORUM
[SOLVED] How to get ratingValue for Google Microdata
- Roman Lipatov
-
Topic Author
- Offline
- New Member
I trying to configure Ratings stars for Google Microdata
I can't understand, hot to get ratingValue
This is code with already working parameters:
aggregateRating [AggregateRating]:
worstRating:
bestRating:
ratingCount:
But without ratingValue
<?php if($params->get('itemRating')): ?>
<div itemprop="aggregateRating" itemscope itemtype="http://schema.org/AggregateRating" class="itemRatingBlock"> <span><?php echo JText::_('K2_RATE_THIS_ITEM'); ?></span>
<meta itemprop="worstRating" content="1">
<meta itemprop="bestRating" content="5">
<div class="itemRatingForm">
<ul class="itemRatingList">
<li class="itemCurrentRating" id="itemCurrentRating<?php echo $this->item->id; ?>" style="width:<?php echo $this->item->votingPercentage; ?>%;"></li>
<li> <a href="#" rel="<?php echo $this->item->id; ?>" title="<?php echo JText::_('K2_1_STAR_OUT_OF_5'); ?>" class="one-star">1</a> </li>
<li> <a href="#" rel="<?php echo $this->item->id; ?>" title="<?php echo JText::_('K2_2_STARS_OUT_OF_5'); ?>" class="two-stars">2</a> </li>
<li> <a href="#" rel="<?php echo $this->item->id; ?>" title="<?php echo JText::_('K2_3_STARS_OUT_OF_5'); ?>" class="three-stars">3</a> </li>
<li> <a href="#" rel="<?php echo $this->item->id; ?>" title="<?php echo JText::_('K2_4_STARS_OUT_OF_5'); ?>" class="four-stars">4</a> </li>
<li> <a href="#" rel="<?php echo $this->item->id; ?>" title="<?php echo JText::_('K2_5_STARS_OUT_OF_5'); ?>" class="five-stars">5</a> </li>
</ul>
<div id="itemRatingLog<?php echo $this->item->id; ?>" class="itemRatingLog" <?php echo $this->item->numOfvotes; ?></div>
<meta itemprop="ratingCount" content="<?php echo (preg_replace('/[^0-9]/', '', $this->item->numOfvotes)); ?>"/>
</div>
</div>
<?php endif; ?>
Thanks!
Please Log in or Create an account to join the conversation.
- Roman Lipatov
-
Topic Author
- Offline
- New Member
<meta itemprop="ratingValue" content="<?php echo (($this->item->votingPercentage)/20);?>"/>
Please Log in or Create an account to join the conversation.
- Krikor Boghossian
-
- Offline
- Platinum Member
- Posts: 15920
Please Log in or Create an account to join the conversation.
- German Levi
-
- Offline
- Premium Member
- Posts: 102
<div class="mdf" itemprop="aggregateRating" itemscope itemtype="http://schema.org/AggregateRating">
<div>Rating
<?php $rating_value = $this->item->votingPercentage; ?>
<?php
$pattern = array("(",")"," ","Голосовать","голосов");
$rating_count = str_replace($pattern,"",$this->item->numOfvotes);
?>
<span itemprop="ratingValue"><?php echo $rating_value * 0.05; ?></span> из
<span itemprop="bestRating">5</span> Голосов:
<span itemprop="ratingCount"><?php echo $rating_count; ?></span>
</div>
</div>
Please Log in or Create an account to join the conversation.
- NormanBLN
-
- Offline
- Junior Member
- Posts: 29
we the same goal for our website. In former times we use the plugin rich snipped vote but since google change the required data this don't work :(
Works this rating now and shows in the search results? With the Structured Data Testing Tool I can't find the [AggregateRating] informations?
The new required data you can find here: developers.google.com/structured-data/rich-snippets/reviews
Do you had a idea to integrate the missing data.
Hey Kirkor Is it a idea to open a github file and so give a fix for all k2 user?
Greetings
Norman
Please Log in or Create an account to join the conversation.
- Krikor Boghossian
-
- Offline
- Platinum Member
- Posts: 15920
Thank you for letting us know.
K2 is already on github github.com/joomlaworks/k2 but I think this is better suited for a gist.
Please Log in or Create an account to join the conversation.
- NormanBLN
-
- Offline
- Junior Member
- Posts: 29
thanks for your answer. I saw this, K2 on grithub, the last time as it gave the probleme with the new update from joomlaand "item must have a title" popup.
Okay - give it a project to integrate the ratingValue for Google? If yes, where I can find this? Give it a plan to integrate that in a k2 update?
I think it's the best way if we create/received the nessary data by k2 as if use another plugins.
Greetings
Norman
Please Log in or Create an account to join the conversation.
- Krikor Boghossian
-
- Offline
- Platinum Member
- Posts: 15920
www.joomlaworks.net/forum/k2-en/42883-item-must-have-a-title-pops-up-after-upgrade-joomla-3-4-4?start=10
As for the microdata I' ll publish something on Github.
Please Log in or Create an account to join the conversation.
- NormanBLN
-
- Offline
- Junior Member
- Posts: 29
thanks for your answer. The first point - I know. I found the here in the forum an JCE published a fix for the editor. :-)
And for two - it is a good Idea :-) Thanks a lot.
Greetings Norman
Please Log in or Create an account to join the conversation.
- Krikor Boghossian
-
- Offline
- Platinum Member
- Posts: 15920
Please Log in or Create an account to join the conversation.
- NormanBLN
-
- Offline
- Junior Member
- Posts: 29
do had news for us?
Greetings
Norman
Please Log in or Create an account to join the conversation.
- NormanBLN
-
- Offline
- Junior Member
- Posts: 29
don't let us not so long wait ..
Please Log in or Create an account to join the conversation.
- Krikor Boghossian
-
- Offline
- Platinum Member
- Posts: 15920
The code provided by Roman is actually correct: schema.org/AggregateRating
Please Log in or Create an account to join the conversation.
- NormanBLN
-
- Offline
- Junior Member
- Posts: 29
I think I need your help.
We try to integrate the code from @Lipatov but this don't work. We replace the code in our item (ourtemplate/html/com_k2/default). This don't work. I was looking for a file with this new code on github (github.com/joomlaworks/k2) but nothing.
I hope you can help us.
<?php if($params->get('itemRating')): ?>
<div itemprop="aggregateRating" itemscope itemtype="http://schema.org/AggregateRating" class="itemRatingBlock"> <span><?php echo JText::_('K2_RATE_THIS_ITEM'); ?></span>
<meta itemprop="worstRating" content="1">
<meta itemprop="bestRating" content="5">
<meta itemprop="ratingValue" content="<?php echo (($this->item->votingPercentage)/20);?>"/>
<div class="itemRatingForm">
<ul class="itemRatingList">
<li class="itemCurrentRating" id="itemCurrentRating<?php echo $this->item->id; ?>" style="width:<?php echo $this->item->votingPercentage; ?>%;">
</li>
<li> <a href="#" rel="<?php echo $this->item->id; ?>" title="<?php echo JText::_('K2_1_STAR_OUT_OF_5'); ?>" class="one-star">1</a> </li>
<li> <a href="#" rel="<?php echo $this->item->id; ?>" title="<?php echo JText::_('K2_2_STARS_OUT_OF_5'); ?>" class="two-stars">2</a> </li>
<li> <a href="#" rel="<?php echo $this->item->id; ?>" title="<?php echo JText::_('K2_3_STARS_OUT_OF_5'); ?>" class="three-stars">3</a> </li>
<li> <a href="#" rel="<?php echo $this->item->id; ?>" title="<?php echo JText::_('K2_4_STARS_OUT_OF_5'); ?>" class="four-stars">4</a> </li>
<li> <a href="#" rel="<?php echo $this->item->id; ?>" title="<?php echo JText::_('K2_5_STARS_OUT_OF_5'); ?>" class="five-stars">5</a> </li>
</ul>
<div id="itemRatingLog<?php echo $this->item->id; ?>" class="itemRatingLog" <?php echo $this->item->numOfvotes; ?></div>
<meta itemprop="ratingCount" content="<?php echo (preg_replace('/[^0-9]/', '', $this->item->numOfvotes)); ?>"/>
</div>
</div>
<?php endif; ?>
Greetings
Norman
Please Log in or Create an account to join the conversation.
- Krikor Boghossian
-
- Offline
- Platinum Member
- Posts: 15920
If on the other hand you followed the instructions as stated here: getk2.org/documentation/tutorials/174-templating-with-k2-and-the-concepts-of-sub-templates and the edits are not shown, then an extension or a template framework is 'blocking' the default process of overrides.
Please Log in or Create an account to join the conversation.
- NormanBLN
-
- Offline
- Junior Member
- Posts: 29
thanks but I know that. I was trying that way. My problem is the correct poistion from the code because if I try that - the template is broken.
I set Lipatov's code instead of the original k2 code and that not work.
Can you give me more details for a work file. Or, you worte on september you will give a working file to github. This is a option to help all of us to fix the rating.
Greetings
Please Log in or Create an account to join the conversation.
- Krikor Boghossian
-
- Offline
- Platinum Member
- Posts: 15920
Other than that the structured data code is correct, there is no need for an edit or a new file.
Please Log in or Create an account to join the conversation.
- NormanBLN
-
- Offline
- Junior Member
- Posts: 29
we found the problem and fix it. Since same month it works fine. Now, we have the problem with the <?php echo $this->item->numOfvotes; ?></div> . The result is: <meta itemprop="ratingCount" content="9Stimmen">. "Stimmen" means votes and google like to have only the number.
Here is the result from the structured-data testing tool: search.google.com/structured-data/testing-tool#url=https%3A%2F%2Foffensichtlich.de%2Fblog%2Ftour-de-france-mit-rudy-project
Do you had a idea for us?
Greetings & Thx
Please Log in or Create an account to join the conversation.
- Krikor Boghossian
-
- Offline
- Platinum Member
- Posts: 15920
You can use str_replace php.net/manual/en/function.str-replace.php in order to manipulate the language string.
Please Log in or Create an account to join the conversation.