Keyword

[SOLVED] How to get ratingValue for Google Microdata

  • Roman Lipatov
  • Roman  Lipatov's Avatar Topic Author
  • Offline
  • New Member
More
9 years 8 months ago - 9 years 8 months ago #146644 by Roman Lipatov
Hi!
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!
Last edit: 9 years 8 months ago by Roman Lipatov.

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

  • Roman Lipatov
  • Roman  Lipatov's Avatar Topic Author
  • Offline
  • New Member
More
9 years 8 months ago - 9 years 8 months ago #146646 by Roman Lipatov
Replied by Roman Lipatov on topic How to get ratingValue for Google Microdata
Ok, I got it
<meta itemprop="ratingValue" content="<?php echo (($this->item->votingPercentage)/20);?>"/>
Last edit: 9 years 8 months ago by Roman Lipatov.

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

  • Krikor Boghossian
  • Krikor Boghossian's Avatar
  • Offline
  • Platinum Member
More
9 years 8 months ago #146670 by Krikor Boghossian
Replied by Krikor Boghossian on topic How to get ratingValue for Google Microdata
You are correct Roman, this is the correct value.

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

More
9 years 8 months ago - 9 years 8 months ago #146970 by German Levi
<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>
Last edit: 9 years 8 months ago by German Levi.

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

More
9 years 7 months ago - 9 years 7 months ago #147642 by NormanBLN
Hello Roman, Hello Krikor,
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
Last edit: 9 years 7 months ago by NormanBLN.

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

  • Krikor Boghossian
  • Krikor Boghossian's Avatar
  • Offline
  • Platinum Member
More
9 years 7 months ago #147653 by Krikor Boghossian
Replied by Krikor Boghossian on topic [SOLVED] How to get ratingValue for Google Microdata
Hello Norman,

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.

More
9 years 7 months ago #147700 by NormanBLN
Hello Krikor,

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
  • Krikor Boghossian's Avatar
  • Offline
  • Platinum Member
More
9 years 7 months ago #147742 by Krikor Boghossian
Replied by Krikor Boghossian on topic [SOLVED] How to get ratingValue for Google Microdata
The first issue has been solved. Please read:
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.

More
9 years 7 months ago #147749 by NormanBLN
Hi Krikor,

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
  • Krikor Boghossian's Avatar
  • Offline
  • Platinum Member
More
9 years 7 months ago #147779 by Krikor Boghossian
Replied by Krikor Boghossian on topic [SOLVED] How to get ratingValue for Google Microdata
I 'll post my gist here Norman :)

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

More
9 years 7 months ago #148219 by NormanBLN
Hi Krikor,
do had news for us?

Greetings
Norman

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

More
9 years 6 months ago #148479 by NormanBLN
Hi Krikor,

don't let us not so long wait ..

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

  • Krikor Boghossian
  • Krikor Boghossian's Avatar
  • Offline
  • Platinum Member
More
9 years 6 months ago #148493 by Krikor Boghossian
Replied by Krikor Boghossian on topic [SOLVED] How to get ratingValue for Google Microdata
Sorry about that,
The code provided by Roman is actually correct: schema.org/AggregateRating

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

More
9 years 5 months ago #149677 by NormanBLN
hi Kirkor,

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
  • Krikor Boghossian's Avatar
  • Offline
  • Platinum Member
More
9 years 5 months ago #149683 by Krikor Boghossian
Replied by Krikor Boghossian on topic [SOLVED] How to get ratingValue for Google Microdata
If you are using more than one K2 subtemplates this post will help you figure which template to edit: www.joomlaworks.net/blog/item/194-k2-inheritance-sub-templating

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.

More
9 years 5 months ago #149691 by NormanBLN
Hi Krikor,

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
  • Krikor Boghossian's Avatar
  • Offline
  • Platinum Member
More
9 years 5 months ago #149693 by Krikor Boghossian
Replied by Krikor Boghossian on topic [SOLVED] How to get ratingValue for Google Microdata
I see an extra closing </div> tag.
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.

More
8 years 8 months ago #157307 by NormanBLN
Hi Krikor,
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
  • Krikor Boghossian's Avatar
  • Offline
  • Platinum Member
More
8 years 8 months ago #157327 by Krikor Boghossian
Replied by Krikor Boghossian on topic [SOLVED] How to get ratingValue for Google Microdata
Sure,
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.


Powered by Kunena Forum