<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>NemoPS &#187; breadcrumbs</title>
	<atom:link href="http://nemops.com/tag/breadcrumbs/feed/" rel="self" type="application/rss+xml" />
	<link>http://nemops.com</link>
	<description>Prestashop Tutorials, Modules and More!</description>
	<lastBuildDate>Wed, 05 Dec 2018 13:25:23 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>https://wordpress.org/?v=4.1.35</generator>
	<item>
		<title>Add Google Rich Snippets Breadcrumbs to Prestashop</title>
		<link>http://nemops.com/prestashop-rich-snippets-breadcrumbs/</link>
		<comments>http://nemops.com/prestashop-rich-snippets-breadcrumbs/#comments</comments>
		<pubDate>Tue, 25 Feb 2014 10:24:30 +0000</pubDate>
		<dc:creator><![CDATA[Nemo]]></dc:creator>
				<category><![CDATA[Tips n Tricks]]></category>
		<category><![CDATA[breadcrumbs]]></category>
		<category><![CDATA[prestashop]]></category>
		<category><![CDATA[rich snippets]]></category>

		<guid isPermaLink="false">http://nemops.com/?p=1883</guid>
		<description><![CDATA[<p>In this tutorial we will see how to add Google Rich Snippets Breadcrumbs to a Prestashop website, by modifying a small portion of the template and using a lightweight override. Version used: Prestashop 1.5.6.2 Two types of markup Google supports the following types of data for the breadcrumbs rich snippets: Microdata RDFa Microdata is the [&#8230;]</p>
<p>The post <a rel="nofollow" href="http://nemops.com/prestashop-rich-snippets-breadcrumbs/">Add Google Rich Snippets Breadcrumbs to Prestashop</a> appeared first on <a rel="nofollow" href="http://nemops.com">NemoPS</a>.</p>
]]></description>
				<content:encoded><![CDATA[<p>In this tutorial we will see how to add Google Rich Snippets Breadcrumbs to a Prestashop website, by modifying a small portion of the template and using a lightweight override.</p>
<p><span id="more-1883"></span></p>
<ul>
<li>Version used: Prestashop 1.5.6.2</li>
</ul>
<h2>Two types of markup</h2>
<p>Google supports the following types of data for the breadcrumbs rich snippets:</p>
<ul>
<li>Microdata</li>
<li>RDFa</li>
</ul>
<p><strong>Microdata</strong> is the one we used in the previous tutorial on <a href="http://nemops.com/prestashop-google-rich-snippets/#.Uwsf7vk7ur0" title="how to add Google Rich Snippets to your Prestashop store">how to add Google Rich Snippets to your Prestashop store</a>, and the basic markup consists in adding itemprops and scopes to single html entities</p>
<p>On the other hand, <strong>RDFa</strong> adds a set of attributes and extensions to html using xml properties. You can read more about it here: <a href="http://en.wikipedia.org/wiki/RDFa" title="RDFa Wiki" rel="nofollow">RDFa Wiki</a>.</p>
<p>I will use the latter in this demonstration, but either will do, so feel free to use the one you prefer in the end. You can visit the <a href="https://support.google.com/customsearch/answer/2595559?hl=en" title="official Google Documentation on Breadcrumbs Rich Snippets" rel="nofollow">official Google Documentation on Breadcrumbs Rich Snippets</a> if you want to get more info about the implementation.</p>
<h2>Adding Google Rich Snippets Breadcrumbs to Prestashop &#8211; The tpl</h2>
<p>First things first, we must hardcode a small portion of code inside <strong>breadcrumb.tpl</strong>. Open up the file located in your theme&#8217;s folder. It will look approximately like this (default theme):</p>
<pre class="brush: php; html-script: true; title: ; notranslate">
&lt;!-- Breadcrumb --&gt;
{if isset($smarty.capture.path)}{assign var='path' value=$smarty.capture.path}{/if}
&lt;div class=&quot;breadcrumb&quot;&gt;
	&lt;a href=&quot;{$base_dir}&quot; title=&quot;{l s='Return to Home'}&quot;&gt;&lt;img src=&quot;{$img_dir}icon/home.gif&quot; height=&quot;26&quot; width=&quot;26&quot; alt=&quot;{l s='Home'}&quot; /&gt;&lt;/a&gt;
	{if isset($path) AND $path}
		&lt;span class=&quot;navigation-pipe&quot; {if isset($category) &amp;&amp; isset($category-&gt;id_category) &amp;&amp; $category-&gt;id_category == 1}style=&quot;display:none;&quot;{/if}&gt;{$navigationPipe|escape:html:'UTF-8'}&lt;/span&gt;
		{if !$path|strpos:'span'}
			&lt;span class=&quot;navigation_page&quot;&gt;{$path}&lt;/span&gt;
		{else}
			{$path}
		{/if}
	{/if}
&lt;/div&gt;
&lt;!-- /Breadcrumb --&gt;
</pre>
<p>Edit as follows:</p>
<pre class="brush: php; html-script: true; title: ; notranslate">
&lt;!-- Breadcrumb --&gt;
{if isset($smarty.capture.path)}{assign var='path' value=$smarty.capture.path}{/if}
&lt;div class=&quot;breadcrumb&quot; xmlns:v=&quot;http://rdf.data-vocabulary.org/#&quot;&gt;
	&lt;span typeof=&quot;v:Breadcrumb&quot;&gt;&lt;a href=&quot;{$base_dir}&quot; rel=&quot;v:url&quot; property=&quot;v:title&quot; title=&quot;{l s='Return to Home'}&quot;&gt;&lt;img src=&quot;{$img_dir}icon/home.gif&quot; height=&quot;26&quot; width=&quot;26&quot; alt=&quot;{l s='Home'}&quot; /&gt;&lt;/a&gt;&lt;/span&gt;
	{if isset($path) AND $path}
		&lt;span class=&quot;navigation-pipe&quot; {if isset($category) &amp;&amp; isset($category-&gt;id_category) &amp;&amp; $category-&gt;id_category == 1}style=&quot;display:none;&quot;{/if}&gt;{$navigationPipe|escape:html:'UTF-8'}&lt;/span&gt;
		{if !$path|strpos:'span'}
			&lt;span typeof=&quot;v:Breadcrumb&quot;&gt;
				&lt;span property=&quot;v:title&quot; class=&quot;navigation_page&quot;&gt;{$path}&lt;/span&gt;
			&lt;/span&gt;
		{else}
			{$path}
		{/if}
	{/if}
&lt;/div&gt;
&lt;!-- /Breadcrumb --&gt;
</pre>
<p><strong>Explanation:</strong> First, we told Google that the .breadcrumb div is our breadcrumb container. Then, we added a span around the homepage link, with <strong>typeof=&#8221;v:Breadcrumb&#8221;</strong> so that it know it&#8217;s dealing with part of the breadcrumb. Lastly, we added a <strong>rel</strong> and <strong>property</strong> attribute to the link pointing to the homepage. Then, we added the breadcrumb object and title property to the last item</p>
<p>At this point, we must use an override as Prestashop builds breadcrumbs in the <strong>Tools::getPath()</strong> method!</p>
<div class="separator"></div>
<h2>Adding Google Rich Snippets Breadcrumbs to Prestashop &#8211; The override</h2>
<p>Create a new override in <em>override/classes</em> and call it <em>Tools.php</em>. Add some regular override markup inside:</p>
<pre class="brush: php; title: ; notranslate">

class Tools extends ToolsCore
{

}
</pre>
<p>We need to override the getPath method, so open the original <strong>Tools.php</strong> class file that you find in your <em>classes/</em> directory, copy the whole <strong>getPath()</strong> method, and paste it inside the new override as follows:</p>
<pre class="brush: php; title: ; notranslate">

class Tools extends ToolsCore
{
	public static function getPath($id_category, $path = '', $link_on_the_item = false, $category_type = 'products', Context $context = null)
	{
		if (!$context)
			$context = Context::getContext();

		$id_category = (int)$id_category;
		if ($id_category == 1)
			return '&lt;span class=&quot;navigation_end&quot;&gt;'.$path.'&lt;/span&gt;';

		$pipe = Configuration::get('PS_NAVIGATION_PIPE');
		if (empty($pipe))
			$pipe = '&gt;';

		$full_path = '';
		if ($category_type === 'products')
		{
			$interval = Category::getInterval($id_category);
			$id_root_category = $context-&gt;shop-&gt;getCategory();
			$interval_root = Category::getInterval($id_root_category);
			if ($interval)
			{
				$sql = 'SELECT c.id_category, cl.name, cl.link_rewrite
						FROM '._DB_PREFIX_.'category c
						LEFT JOIN '._DB_PREFIX_.'category_lang cl ON (cl.id_category = c.id_category'.Shop::addSqlRestrictionOnLang('cl').')
						WHERE c.nleft &lt;= '.$interval['nleft'].'
							AND c.nright &gt;= '.$interval['nright'].'
							AND c.nleft &gt;= '.$interval_root['nleft'].'
							AND c.nright &lt;= '.$interval_root['nright'].'
							AND cl.id_lang = '.(int)$context-&gt;language-&gt;id.'
							AND c.active = 1
							AND c.level_depth &gt; '.(int)$interval_root['level_depth'].'
						ORDER BY c.level_depth ASC';
				$categories = Db::getInstance()-&gt;executeS($sql);

				$n = 1;
				$n_categories = count($categories);
				foreach ($categories as $category)
				{
					$full_path .=
					(($n &lt; $n_categories || $link_on_the_item) ? '&lt;a href=&quot;'.Tools::safeOutput($context-&gt;link-&gt;getCategoryLink((int)$category['id_category'], $category['link_rewrite'])).'&quot; title=&quot;'.htmlentities($category['name'], ENT_NOQUOTES, 'UTF-8').'&quot;&gt;' : '').
					htmlentities($category['name'], ENT_NOQUOTES, 'UTF-8').
					(($n &lt; $n_categories || $link_on_the_item) ? '&lt;/a&gt;' : '').
					(($n++ != $n_categories || !empty($path)) ? '&lt;span class=&quot;navigation-pipe&quot;&gt;'.$pipe.'&lt;/span&gt;' : '');
				}

				return $full_path.$path;
			}
		}
		else if ($category_type === 'CMS')
		{
			$category = new CMSCategory($id_category, $context-&gt;language-&gt;id);
			if (!Validate::isLoadedObject($category))
				die(Tools::displayError());
			$category_link = $context-&gt;link-&gt;getCMSCategoryLink($category);

			if ($path != $category-&gt;name)
				$full_path .= '&lt;a href=&quot;'.Tools::safeOutput($category_link).'&quot;&gt;'.htmlentities($category-&gt;name, ENT_NOQUOTES, 'UTF-8').'&lt;/a&gt;&lt;span class=&quot;navigation-pipe&quot;&gt;'.$pipe.'&lt;/span&gt;'.$path;
			else
				$full_path = ($link_on_the_item ? '&lt;a href=&quot;'.Tools::safeOutput($category_link).'&quot;&gt;' : '').htmlentities($path, ENT_NOQUOTES, 'UTF-8').($link_on_the_item ? '&lt;/a&gt;' : '');

			return Tools::getPath($category-&gt;id_parent, $full_path, $link_on_the_item, $category_type);
		}
	}
}
</pre>
<p>We can now modify the code snippets that generate links. First off, locate:</p>
<pre class="brush: php; title: ; notranslate">
		if (!$context)
			$context = Context::getContext();

</pre>
<p>Right after it, add</p>
<pre class="brush: php; title: ; notranslate">
	$path = '&lt;span typeof=&quot;v:Breadcrumb&quot;&gt;&lt;span property=&quot;v:title&quot;&gt;'.$path.'&lt;/span&gt;&lt;/span&gt;';
</pre>
<p>This way we label the current page name as title in the breadcrumbs. Then:</p>
<pre class="brush: php; title: ; notranslate">
					$full_path .=
					(($n &lt; $n_categories || $link_on_the_item) ? '&lt;a href=&quot;'.Tools::safeOutput($context-&gt;link-&gt;getCategoryLink((int)$category['id_category'], $category['link_rewrite'])).'&quot; title=&quot;'.htmlentities($category['name'], ENT_NOQUOTES, 'UTF-8').'&quot;&gt;' : '').
					htmlentities($category['name'], ENT_NOQUOTES, 'UTF-8').
					(($n &lt; $n_categories || $link_on_the_item) ? '&lt;/a&gt;' : '').

</pre>
<p>Edit as follows</p>
<pre class="brush: php; title: ; notranslate">
					$full_path .=
					(($n &lt; $n_categories || $link_on_the_item) ? '&lt;span typeof=&quot;v:Breadcrumb&quot;&gt; &lt;a rel=&quot;v:url&quot; property=&quot;v:title&quot; href=&quot;'.Tools::safeOutput($context-&gt;link-&gt;getCategoryLink((int)$category['id_category'], $category['link_rewrite'])).'&quot; title=&quot;'.htmlentities($category['name'], ENT_NOQUOTES, 'UTF-8').'&quot;&gt;' : '').
					htmlentities($category['name'], ENT_NOQUOTES, 'UTF-8').
					(($n &lt; $n_categories || $link_on_the_item) ? '&lt;/a&gt; &lt;/span&gt;' : '').
</pre>
<p><strong>Explanation:</strong> as we did previously, we added a span around the link, and assigned a rel and property attributes to the inner link. <strong>Remember to close the span at the end!</strong>.</p>
<p>Lastly, let&#8217;s account for cms pages as well, find:</p>
<pre class="brush: php; title: ; notranslate">
			if ($path != $category-&gt;name)
				$full_path .= '&lt;a href=&quot;'.Tools::safeOutput($category_link).'&quot;&gt;'.htmlentities($category-&gt;name, ENT_NOQUOTES, 'UTF-8').'&lt;/a&gt;&lt;span class=&quot;navigation-pipe&quot;&gt;'.$pipe.'&lt;/span&gt;'.$path;
			else
				$full_path = ($link_on_the_item ? '&lt;a href=&quot;'.Tools::safeOutput($category_link).'&quot;&gt;' : '').htmlentities($path, ENT_NOQUOTES, 'UTF-8').($link_on_the_item ? '&lt;/a&gt;' : '');
</pre>
<p>And change it to:</p>
<pre class="brush: php; title: ; notranslate">
			if ($path != $category-&gt;name)
				$full_path .= '&lt;span typeof=&quot;v:Breadcrumb&quot;&gt; &lt;a rel=&quot;v:url&quot; property=&quot;v:title&quot; href=&quot;'.Tools::safeOutput($category_link).'&quot;&gt;'.htmlentities($category-&gt;name, ENT_NOQUOTES, 'UTF-8').'&lt;/a&gt; &lt;/span&gt; &lt;span class=&quot;navigation-pipe&quot;&gt; '.$pipe.' &lt;/span&gt; '.$path;
			else
				$full_path = ($link_on_the_item ? '&lt;span typeof=&quot;v:Breadcrumb&quot;&gt; &lt;a rel=&quot;v:url&quot; property=&quot;v:title&quot; href=&quot;'.Tools::safeOutput($category_link).'&quot;&gt;' : '').htmlentities($path, ENT_NOQUOTES, 'UTF-8').($link_on_the_item ? '&lt;/a&gt; &lt;span&gt;' : '');
</pre>
<p>We are done! Save, clear smarty cache/force compile so that changes take effect, then go to <em>cache/</em> and erase <strong>class_index.php</strong> so that the override can take place!</p>
<p>The final override:</p>
<pre class="brush: php; title: ; notranslate">

class Tools extends ToolsCore
{


	public static function getPath($id_category, $path = '', $link_on_the_item = false, $category_type = 'products', Context $context = null)
	{
		if (!$context)
			$context = Context::getContext();

		$path = '&lt;span typeof=&quot;v:Breadcrumb&quot;&gt;&lt;span property=&quot;v:title&quot;&gt;'.$path.'&lt;/span&gt;&lt;/span&gt;';

		$id_category = (int)$id_category;
		if ($id_category == 1)
			return '&lt;span class=&quot;navigation_end&quot;&gt;'.$path.'&lt;/span&gt;';

		$pipe = Configuration::get('PS_NAVIGATION_PIPE');
		if (empty($pipe))
			$pipe = '&gt;';

		$full_path = '';
		if ($category_type === 'products')
		{
			$interval = Category::getInterval($id_category);
			$id_root_category = $context-&gt;shop-&gt;getCategory();
			$interval_root = Category::getInterval($id_root_category);
			if ($interval)
			{
				$sql = 'SELECT c.id_category, cl.name, cl.link_rewrite
						FROM '._DB_PREFIX_.'category c
						LEFT JOIN '._DB_PREFIX_.'category_lang cl ON (cl.id_category = c.id_category'.Shop::addSqlRestrictionOnLang('cl').')
						WHERE c.nleft &lt;= '.$interval['nleft'].'
							AND c.nright &gt;= '.$interval['nright'].'
							AND c.nleft &gt;= '.$interval_root['nleft'].'
							AND c.nright &lt;= '.$interval_root['nright'].'
							AND cl.id_lang = '.(int)$context-&gt;language-&gt;id.'
							AND c.active = 1
							AND c.level_depth &gt; '.(int)$interval_root['level_depth'].'
						ORDER BY c.level_depth ASC';
				$categories = Db::getInstance()-&gt;executeS($sql);

				$n = 1;
				$n_categories = count($categories);
				foreach ($categories as $category)
				{
					$full_path .=
					(($n &lt; $n_categories || $link_on_the_item) ? '&lt;span typeof=&quot;v:Breadcrumb&quot;&gt; &lt;a rel=&quot;v:url&quot; property=&quot;v:title&quot; href=&quot;'.Tools::safeOutput($context-&gt;link-&gt;getCategoryLink((int)$category['id_category'], $category['link_rewrite'])).'&quot; title=&quot;'.htmlentities($category['name'], ENT_NOQUOTES, 'UTF-8').'&quot;&gt;' : '').
					htmlentities($category['name'], ENT_NOQUOTES, 'UTF-8').
					(($n &lt; $n_categories || $link_on_the_item) ? '&lt;/a&gt; &lt;/span&gt;' : '').
					(($n++ != $n_categories || !empty($path)) ? ' &lt;span class=&quot;navigation-pipe&quot;&gt; '.$pipe.' &lt;/span&gt; ' : '');
				}

				return $full_path.$path;
			}
		}
		else if ($category_type === 'CMS')
		{
			$category = new CMSCategory($id_category, $context-&gt;language-&gt;id);
			if (!Validate::isLoadedObject($category))
				die(Tools::displayError());
			$category_link = $context-&gt;link-&gt;getCMSCategoryLink($category);

			if ($path != $category-&gt;name)
				$full_path .= '&lt;span typeof=&quot;v:Breadcrumb&quot;&gt; &lt;a rel=&quot;v:url&quot; property=&quot;v:title&quot; href=&quot;'.Tools::safeOutput($category_link).'&quot;&gt;'.htmlentities($category-&gt;name, ENT_NOQUOTES, 'UTF-8').'&lt;/a&gt; &lt;/span&gt; &lt;span class=&quot;navigation-pipe&quot;&gt; '.$pipe.' &lt;/span&gt; '.$path;
			else
				$full_path = ($link_on_the_item ? '&lt;span typeof=&quot;v:Breadcrumb&quot;&gt; &lt;a rel=&quot;v:url&quot; property=&quot;v:title&quot;  href=&quot;'.Tools::safeOutput($category_link).'&quot;&gt;' : '').htmlentities($path, ENT_NOQUOTES, 'UTF-8').($link_on_the_item ? '&lt;/a&gt; &lt;span&gt;' : '');

			return Tools::getPath($category-&gt;id_parent, $full_path, $link_on_the_item, $category_type);
		}
	}

}
</pre>
<p>Time to test your page now! Here is one from my <a href="http://store.nemops.com" title="Prestashop modules store">Prestashop modules store</a>: <strong><a href="http://www.google.com/webmasters/tools/richsnippets?q=http%3A%2F%2Fstore.nemops.com%2Fseo%2F29-prestashop-seo-booster.html" target="_blank" rel="nofollow" title="Prestashop SEO Booster example">Prestashop SEO Booster example</a></strong></p>
<p>The post <a rel="nofollow" href="http://nemops.com/prestashop-rich-snippets-breadcrumbs/">Add Google Rich Snippets Breadcrumbs to Prestashop</a> appeared first on <a rel="nofollow" href="http://nemops.com">NemoPS</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://nemops.com/prestashop-rich-snippets-breadcrumbs/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
	</channel>
</rss>
