News function Microdata with your hikashop

  • Posts: 13
  • Thank you received: 0
9 years 6 months ago #200905

-- HikaShop version -- : latest
-- Joomla version -- : latest
-- PHP version -- : 5.5.x
-- Error-message(debug-mod must be tuned on) -- : not a problem

Hello,
Can you add microdata with your component available on https://docs.joomla.org/Microdata

it easy to but for news version from your component i always change that..

Thank regards


-- Website: www.alexonbalangue.me , www.livingxworld.com
-- HikaShop version -- : Free latest
-- Joomla version -- : 3.5.X
-- PHP version -- : 7.0.4

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

  • Posts: 13201
  • Thank you received: 2322
9 years 6 months ago #200926

Hi,

Microdatas are present in HikaShop thanks to the plugin "system / hikashopproducttag".
It add the itemprop/itemscope and itemtype attributes on the products.

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

  • Posts: 13
  • Thank you received: 0
9 years 6 months ago #201019

i saw and activate this plg purge all cache/logs, i see the sources code on front-end not show.
i see too the source code the plg have dooble defined. line 9 to line 11.
But only for product pages this plg..


Why not edit from this folder
> /www/components/com_hikashop/views/****
> /www/components/com_hikashop/views/product/tmpl/default.php

For simplie without preg_replace use directly with this libreary of joomla.in your component.

thanks again


-- Website: www.alexonbalangue.me , www.livingxworld.com
-- HikaShop version -- : Free latest
-- Joomla version -- : 3.5.X
-- PHP version -- : 7.0.4
Attachments:

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

  • Posts: 82863
  • Thank you received: 13372
  • MODERATOR
9 years 6 months ago #201026

Hi,

We don't add the microdata directly in the view so that it will work even with template overrides of the product page.

If you don't see the microdata with the latest version, it might be because of a bug that we already fixed in the plugin.
Download again the install package of HikaShop and install it again on your website and it will add the patch to the plugin.

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

  • Posts: 13
  • Thank you received: 0
9 years 6 months ago #201115

only product pages not categories or/and other pages too its work well but have a error
see



- dooble ID + end code ">" have dooble quote ' " "

or i make it contribution for microdata than use plugin or so...


-- Website: www.alexonbalangue.me , www.livingxworld.com
-- HikaShop version -- : Free latest
-- Joomla version -- : 3.5.X
-- PHP version -- : 7.0.4
Attachments:

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

  • Posts: 13201
  • Thank you received: 2322
9 years 6 months ago #201133

Hi,

Please use that code, or check if the code you currently have is the same.

<?php
defined('_JEXEC') or die('Restricted access');
?>
<?php

class plgSystemHikashopproducttag extends JPlugin {
	function onHikashopBeforeDisplayView(&$view){
		$option = JRequest::getString('option');
		$ctrl = JRequest::getString('ctrl');
		$task = JRequest::getString('task');

		if ($option!='com_hikashop'||$ctrl!='product'||$task!='show') return;

		ob_start();
	}
	function onHikashopAfterDisplayView(&$view){
		$option = JRequest::getString('option');
		$ctrl = JRequest::getString('ctrl');
		$task = JRequest::getString('task');

		if ($option!='com_hikashop'||$ctrl!='product'||$task!='show') return;

		$config =& hikashop_config();
		$default_params = $config->get('default_params');

		$product_page = ob_get_clean();

		$product_page_parts = explode('class="hikashop_product_page ', $product_page);
		if(!empty($product_page_parts[1])){
			$product_page_parts[1] = 'itemscope itemtype="http://schema.org/Product" class="hikashop_product_page ' .$product_page_parts[1];

			//name
			$pattern='/id="hikashop_product_name_main"/';
			$replacement='id="hikashop_product_name_main" itemprop="name"';
			$product_page_parts[1] = preg_replace($pattern,$replacement,$product_page_parts[1],1);
			//price
			if($default_params['show_price'] == 1){
				$currency_id = hikashop_getCurrency();
				$null = null;
				$currencyClass = hikashop_get('class.currency');
				$currencies = $currencyClass->getCurrencies($currency_id,$null);
				$data=$currencies[$currency_id];

				//DIV offer
				$pattern='/<span id="hikashop_product_price_main" class="hikashop_product_price_main">/';
				$replacement= '<div itemprop="offers" itemscope itemtype="http://schema.org/Offer"><span id="hikashop_product_price_main" class="hikashop_product_price_main"><meta itemprop="priceCurrency" content="'.$data->currency_code.'" />';
				$product_page_parts[1] = preg_replace($pattern,$replacement,$product_page_parts[1],1);
				//EO DIV offer
				$pattern='/<(span|div) id="(hikashop_product_weight_main|hikashop_product_width_main|hikashop_product_length_main|hikashop_product_height_main|hikashop_product_characteristics|hikashop_product_options|hikashop_product_custom_item_info|hikashop_product_price_with_options_main|hikashop_product_quantity_main)"/';
				$replacement='</div> <$1 id="$2"';
				$product_page_parts[1] = preg_replace($pattern,$replacement,$product_page_parts[1],1);
				//itemprop
				$pattern='/class="hikashop_product_price_main"(.*)class="hikashop_product_price hikashop_product_price_0/msU';
				$replacement='class="hikashop_product_price_main" $1 itemprop="price" class="hikashop_product_price hikashop_product_price_0';
				$product_page_parts[1] = preg_replace($pattern,$replacement,$product_page_parts[1],1);
			}
			//vote == review
			$pattern='/id="hikashop_product_vote_listing"/';
			$replacement='id="hikashop_product_vote_listing" itemscope itemtype="http://schema.org/Review"';
			$product_page_parts[1] = preg_replace($pattern,$replacement,$product_page_parts[1],1);

			if(strpos($product_page_parts[1],'class="hika_comment_listing_empty"')==false){
				$pattern='/class="ui-corner-all hika_comment_listing"/';
				$replacement='class="ui-corner-all hika_comment_listing" itemprop="review" itemscope itemtype="http://schema.org/Review"';
				$product_page_parts[1] = preg_replace($pattern,$replacement,$product_page_parts[1]);
			}

			// Comment
			$pattern='/class="hikashop_vote_listing_comment"/';
			$replacement='class="hikashop_vote_listing_comment" itemprop="description"';
			$product_page_parts[1] = preg_replace($pattern,$replacement,$product_page_parts[1]);

			$pattern='/class="hika_comment_listing_content"/';
			$replacement='class="hika_comment_listing_content" itemprop="description"';
			$product_page_parts[1] = preg_replace($pattern,$replacement,$product_page_parts[1]);
			//Comment - Author
			$pattern='/class="hikashop_vote_listing_username"/';
			$replacement='class="hikashop_vote_listing_username" itemprop="author"';
			$product_page_parts[1] = preg_replace($pattern,$replacement,$product_page_parts[1]);

			$pattern='/class="hika_vote_listing_username"/';
			$replacement='class="hika_vote_listing_username" itemprop="author"';
			$product_page_parts[1] = preg_replace($pattern,$replacement,$product_page_parts[1]);
			//Product description
			$pattern='/class="hikashop_product_description_main"/';
			$replacement='class="hikashop_product_description_main" itemprop="description"';
			$product_page_parts[1] = preg_replace($pattern,$replacement,$product_page_parts[1],1);
			//Product rate
			$pattern='/class="hikashop_vote_stars"/';
			$replacement='class="hikashop_vote_stars" itemprop="aggregateRating" itemscope itemtype="http://schema.org/AggregateRating"';
			$product_page_parts[1] = preg_replace($pattern,$replacement,$product_page_parts[1],1);
			//Product image
			$pattern='/id="hikashop_main_image"/';
			$replacement='id="hikashop_main_image" itemprop="image"';
			$product_page_parts[1] = preg_replace($pattern,$replacement,$product_page_parts[1]);

			//$ratevalue=JRequest::getVar("nb_star");
			$ratemax=JRequest::getVar("nb_max_star");//nbmax
			$raterounded=JRequest::getVar("rate_rounded");//moy
			$pattern='/(<span\s+class="hikashop_total_vote")/iUs';
			$replacement = '<span style="display:none" itemprop="ratingValue">'.$raterounded.'</span><span style="display:none" itemprop="bestRating">'.$ratemax.'</span>$1 itemprop="reviewCount"';
			$product_page_parts[1] = preg_replace($pattern,$replacement,$product_page_parts[1],1);


			//new dbug($product_page_parts[1]);
		}
		foreach($product_page_parts as $parts){
			echo $parts;
		}
	}
}
I don't see errors in that code, and I was not able to reproduce the issue on my local.

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

Time to create page: 0.125 seconds
Powered by Kunena Forum