Keyword

K2 Rating on Google

  • Goble002
  • Goble002's Avatar Topic Author
  • Offline
  • Premium Member
More
8 years 6 months ago #159441 by Goble002
K2 Rating on Google was created by Goble002
Hello,

I've searched a bit on the forum but the related posts are a bit old.

Running K2 2.7.1 with template override. Is there actually a plugin that can be used to get Rating Value for Google Mircrodata ?

Or else, is there already some specific codes out there which I can use ?


Thanks !

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

  • Krikor Boghossian
  • Krikor Boghossian's Avatar
  • Offline
  • Platinum Member
More
8 years 6 months ago #159452 by Krikor Boghossian

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

  • Goble002
  • Goble002's Avatar Topic Author
  • Offline
  • Premium Member
More
8 years 6 months ago #159535 by Goble002
Replied by Goble002 on topic K2 Rating on Google
Hi and thanks,

I read this post before. However some people reported having issues with their codes, I was wondering if you have one that works for sure.

P.S. Am not a PHP coder.

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

  • Krikor Boghossian
  • Krikor Boghossian's Avatar
  • Offline
  • Platinum Member
More
8 years 5 months ago #159557 by Krikor Boghossian
Replied by Krikor Boghossian on topic K2 Rating on Google
I have tested the code, it should work fine.
The complaints were that the reviews code should be used, instead.
The rating microdata is however correct.

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

  • Goble002
  • Goble002's Avatar Topic Author
  • Offline
  • Premium Member
More
8 years 5 months ago #159587 by Goble002
Replied by Goble002 on topic K2 Rating on Google
Hello Krikor and thanks,

am not sure what you meant by "the reviews code should be used'. Anyway I have used hereunder but errors with Google 'structured data testing tool' search.google.com/structured-data/testing-tool
<?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; ?>

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

  • Krikor Boghossian
  • Krikor Boghossian's Avatar
  • Offline
  • Platinum Member
More
8 years 5 months ago #159614 by Krikor Boghossian
Replied by Krikor Boghossian on topic K2 Rating on Google
There are different settings for reviews and different for ratings.
Have you posted the code in your site so I can take a look?

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

  • Goble002
  • Goble002's Avatar Topic Author
  • Offline
  • Premium Member
More
8 years 5 months ago #159624 by Goble002
Replied by Goble002 on topic K2 Rating on Google
Hello Krikor and thanks,

got error hereunder when I include them on my website:

Fatal error: Call to a member function get() on null in .../templates/my_template/html/com_k2/item/item.php on line 191

Line 191 starts with:
<?php if($params->get('itemRating')): ?>

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

  • Goble002
  • Goble002's Avatar Topic Author
  • Offline
  • Premium Member
More
8 years 5 months ago #159726 by Goble002
Replied by Goble002 on topic K2 Rating on Google
Hello,

any update on above ? Thanks !

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

  • Goble002
  • Goble002's Avatar Topic Author
  • Offline
  • Premium Member
More
8 years 5 months ago #159795 by Goble002
Replied by Goble002 on topic K2 Rating on Google
Hello,

any update on above ? Thanks !

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

  • Goble002
  • Goble002's Avatar Topic Author
  • Offline
  • Premium Member
More
8 years 5 months ago #159822 by Goble002
Replied by Goble002 on topic K2 Rating on Google
Hi all,

desperately needing to include this in K2, anyone been able to make it work ? Any plugin that exists that would do the job ?

Thanks !

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

  • Krikor Boghossian
  • Krikor Boghossian's Avatar
  • Offline
  • Platinum Member
More
8 years 5 months ago #159825 by Krikor Boghossian
Replied by Krikor Boghossian on topic K2 Rating on Google
Hello,

The correct parameter statement should be:
<?php if($this->item->params->get('itemRating')): ?>

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

  • Goble002
  • Goble002's Avatar Topic Author
  • Offline
  • Premium Member
More
8 years 5 months ago #159833 by Goble002
Replied by Goble002 on topic K2 Rating on Google
Thanks,

no errors now. However search.google.com/structured-data/testing-tool does not detect any structured data.

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

  • Krikor Boghossian
  • Krikor Boghossian's Avatar
  • Offline
  • Platinum Member
More
8 years 5 months ago #159855 by Krikor Boghossian
Replied by Krikor Boghossian on topic K2 Rating on Google
I will need a link in order to check this.

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

  • Goble002
  • Goble002's Avatar Topic Author
  • Offline
  • Premium Member
More
8 years 5 months ago #159863 by Goble002
Replied by Goble002 on topic K2 Rating on Google
Hello Krikor,

The link: www.webs800.com/en/services/web-development/web-design-maintenance

I just noticed that I wrongly pasted the code last time which made me thought that were no more errors (sometimes errors seem to occur when you copy large amount of codes in template overrides).

Anyway with the code hereunder, it will just break the layout of my page. So I reverted back to the codes without microdata.
	<?php if($this->item->params->get('itemRating')): ?>
	<!-- Item Rating -->
	<div class="itemRatingBlock">
		<span><?php echo JText::_('K2_RATE_THIS_ITEM'); ?></span>
		<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="#" data-id="<?php echo $this->item->id; ?>" title="<?php echo JText::_('K2_1_STAR_OUT_OF_5'); ?>" class="one-star">1</a></li>
				<li><a href="#" data-id="<?php echo $this->item->id; ?>" title="<?php echo JText::_('K2_2_STARS_OUT_OF_5'); ?>" class="two-stars">2</a></li>
				<li><a href="#" data-id="<?php echo $this->item->id; ?>" title="<?php echo JText::_('K2_3_STARS_OUT_OF_5'); ?>" class="three-stars">3</a></li>
				<li><a href="#" data-id="<?php echo $this->item->id; ?>" title="<?php echo JText::_('K2_4_STARS_OUT_OF_5'); ?>" class="four-stars">4</a></li>
				<li><a href="#" data-id="<?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>
			<div class="clr"></div>
		</div>
		<div class="clr"></div>
	</div>
	<?php endif; ?>

With this code also Structured Data Testing Tool says: The review has no reviewed item specified.

So I have also tried with
<span itemprop="itemreviewed"><?php echo JText::_('K2_RATE_THIS_ITEM'); ?></span>
instead but no change

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

  • Krikor Boghossian
  • Krikor Boghossian's Avatar
  • Offline
  • Platinum Member
More
8 years 5 months ago #159891 by Krikor Boghossian
Replied by Krikor Boghossian on topic K2 Rating on Google
Viewing www.webs800.com/en/services/web-development/web-design-maintenance 's source and I could not find any other structured data (itemprop).

There is an example here with more complete code, but only try the itemprop values not the PHP part.
github.com/kricore/Advanced-templating-with-K2/blob/master/default/item.php

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

  • Goble002
  • Goble002's Avatar Topic Author
  • Offline
  • Premium Member
More
8 years 5 months ago #159899 by Goble002
Replied by Goble002 on topic K2 Rating on Google
Hello Krikor and thanks,

like mentioned the code was breaking my layout so I had to remove it. I have made a copy of the website and use the code here:
www.webs800.com/webs801/en/services/web-development/web-design-maintenance

In the link you sent, there are no: itemprop="itemreviewed"
This is what is missing as per Google Structured Data Testing Tool

Thanks again for your help !

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

  • Krikor Boghossian
  • Krikor Boghossian's Avatar
  • Offline
  • Platinum Member
More
8 years 5 months ago #159918 by Krikor Boghossian
Replied by Krikor Boghossian on topic K2 Rating on Google
It is not that simple, the ratings code belong to an object (structured data entity)
If the object is not defined, which in this case is the article, the rating code will not be picked up.

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


Powered by Kunena Forum