<?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; navigation</title>
	<atom:link href="http://nemops.com/tag/navigation/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>How to create a &#8220;Go back to the category&#8221; button in PrestaShop and thirty bees</title>
		<link>http://nemops.com/how-to-create-a-go-back-to-the-category-button-in-prestashop-and-thirty-bees/</link>
		<comments>http://nemops.com/how-to-create-a-go-back-to-the-category-button-in-prestashop-and-thirty-bees/#comments</comments>
		<pubDate>Mon, 09 Apr 2018 10:56:55 +0000</pubDate>
		<dc:creator><![CDATA[Nemo]]></dc:creator>
				<category><![CDATA[Tips n Tricks]]></category>
		<category><![CDATA[button]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[navigation]]></category>
		<category><![CDATA[prestashop 1.6]]></category>
		<category><![CDATA[thirtybees]]></category>

		<guid isPermaLink="false">http://nemops.com/?p=3125</guid>
		<description><![CDATA[<p>In this video we will make a handy button to let our customers navigate back to the previously visited category from the product page, in PrestaShop 1.6 and thirty bees Watch the screencast Text Version To start with, open up global.js, located in your theme folder /js. At the very end, add the following: Then, [&#8230;]</p>
<p>The post <a rel="nofollow" href="http://nemops.com/how-to-create-a-go-back-to-the-category-button-in-prestashop-and-thirty-bees/">How to create a &#8220;Go back to the category&#8221; button in PrestaShop and thirty bees</a> appeared first on <a rel="nofollow" href="http://nemops.com">NemoPS</a>.</p>
]]></description>
				<content:encoded><![CDATA[<p>In this video we will make a handy button to let our customers navigate back to the previously visited category from the product page, in PrestaShop 1.6 and thirty bees<br />
<span id="more-3125"></span></p>
<h2>Watch the screencast</h2>

	<div class="video-embed">
		<iframe width="640" height="360" src="http://www.youtube.com/embed/nOR7f_76LHE" frameborder="0" allowfullscreen></iframe><p><a href="https://www.youtube.com/user/NemoPostScriptum/videos" rel="nofollow" title="Subscribe Post Scriptum's Youtube Channel">Subscribe Post Scriptum's Youtube Channel</a></p>	</div>
<h2>Text Version</h2>
<p>To start with, open up <strong>global.js</strong>, located in your theme folder <em>/js</em>. At the very end, add the following:</p>
<pre class="brush: jscript; title: ; notranslate">

$(document).ready(function() {
	if($('body').hasClass('category'))
	{
		$('.product_img_link').click(function(e) {
			$.totalStorage('last_visited_category', window.location.href);
		});
	}
});
</pre>
<p>Then, in <strong>product.tpl</strong>, again in the theme folder, find a proper spot for the button, then add the following inside a &lt;script&gt; tag:</p>
<pre class="brush: jscript; title: ; notranslate">
	$(document).ready(function() {
		if(previous_category = $.totalStorage('last_visited_category'))
		{
			$('#goback').attr('href', previous_category);
			$.totalStorage('last_visited_category', '');
		} else $('#goback').hide();
	});
</pre>
<p>Right after id, add our button:</p>
<pre class="brush: xml; title: ; notranslate">

&lt;a href=&quot;javascript:void(0)&quot; class=&quot;btn btn-default&quot; id=&quot;goback&quot;&gt;
	&lt;i class=&quot;icon-chevron-left left&quot;&gt;&lt;/i&gt; {l s='Go Back to the last category'}
&lt;/a&gt;
</pre>
<p>Here is the final code for product.tpl</p>
<pre class="brush: xml; title: ; notranslate">
&lt;script&gt;

	$(document).ready(function() {
		if(previous_category = $.totalStorage('last_visited_category'))
		{
			$('#goback').attr('href', previous_category);
			$.totalStorage('last_visited_category', '');
		} else $('#goback').hide();
	});
&lt;/script&gt;

&lt;a href=&quot;javascript:void(0)&quot; class=&quot;btn btn-default&quot; id=&quot;goback&quot;&gt;
	&lt;i class=&quot;icon-chevron-left left&quot;&gt;{l s='Go Back to the last category'}&lt;/i&gt;
&lt;/a&gt;

</pre>
<p><strong>Notice:</strong> If you want to keep a record of the visited category across pages, you can remove <strong>$.totalStorage(&#8216;last_visited_category&#8217;, &#8221;);</strong> from the code in product.tpl.</p>
<p>The post <a rel="nofollow" href="http://nemops.com/how-to-create-a-go-back-to-the-category-button-in-prestashop-and-thirty-bees/">How to create a &#8220;Go back to the category&#8221; button in PrestaShop and thirty bees</a> appeared first on <a rel="nofollow" href="http://nemops.com">NemoPS</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://nemops.com/how-to-create-a-go-back-to-the-category-button-in-prestashop-and-thirty-bees/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Adding Previous and Next navigation buttons to the Prestashop product page</title>
		<link>http://nemops.com/prestashop-previous-next-product-buttons/</link>
		<comments>http://nemops.com/prestashop-previous-next-product-buttons/#comments</comments>
		<pubDate>Tue, 30 Sep 2014 07:57:22 +0000</pubDate>
		<dc:creator><![CDATA[Nemo]]></dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[navigation]]></category>
		<category><![CDATA[prestashop]]></category>
		<category><![CDATA[product]]></category>

		<guid isPermaLink="false">http://nemops.com/?p=2161</guid>
		<description><![CDATA[<p>To allow an easier navigation through categories, let&#8217;s add Previous and Next product navigation buttons to each product page in Prestashop Prestashop version: 1.5, 1.6 Please notice project files are from 1.6.0.9 Introduction Although I only tested this code on Prestashop 1.6, it should equally work on 1.5 as the database structure didn&#8217;t change. That [&#8230;]</p>
<p>The post <a rel="nofollow" href="http://nemops.com/prestashop-previous-next-product-buttons/">Adding Previous and Next navigation buttons to the Prestashop product page</a> appeared first on <a rel="nofollow" href="http://nemops.com">NemoPS</a>.</p>
]]></description>
				<content:encoded><![CDATA[<p>To allow an easier navigation through categories, let&#8217;s add Previous and Next product navigation buttons to each product page in Prestashop</p>
<p><span id="more-2161"></span></p>
<ul>
<li>Prestashop version: <strong>1.5, 1.6</strong></li>
</ul>
<a class="download-files button style1" href="http://nemops.com/wp-content/uploads/2014/09/prevnext_tut.zip" title="Download Project Files">Download Project Files</a>
<p>Please notice project files are from 1.6.0.9</p>
<h2>Introduction</h2>
<p>Although I only tested this code on Prestashop 1.6, it should equally work on 1.5 as the database structure didn&#8217;t change. That said, we need to edit/extend the following files:</p>
<ul>
<li>classes/Product.php (to grab previous and next products)</li>
<li>controllers/front/ProductController.php (to assign links to the template)</li>
<li>themes/default-bootstrap/product.tpl (to add the buttons)</li>
</ul>
<p>As always, I recommend overriding whenever possible; therefore, we will extend the first 2 files and directly modify the template one.</p>
<p>Additionally, given that a product can belong to different categories, we will only navigate through the default one, to make things easier.</p>
<div class="separator"></div>
<h2>Step 1 &#8211; Retrieving the previous and next product</h2>
<p>First off, we need some data to work with. Neither previous nor next product are assigned to the product page, so we need to get them first. As mentioned above, to simplify we will only retrieve the ones that come before and after in the default product category. It is indeed possible to use the previously visited category, but things can get quite complicated and overly troublesome (it might be a good subject for another tutorial though!).</p>
<p>Create a new file inside <em>override/classes</em> and call it <strong>Product.php</strong>, and paste the following inside php tags:</p>
<pre class="brush: php; title: ; notranslate">
class Product extends ProductCore
{
}
</pre>
<p>Then, let&#8217;s create the method we need, and start by grabbing the current product&#8217;s position in its default category:</p>
<pre class="brush: php; title: ; notranslate">

	public function getAdjacentProducts()
	{

		$position  = Db::getInstance()-&gt;getValue('SELECT position FROM '._DB_PREFIX_.'category_product WHERE id_product = ' . (int)$this-&gt;id . ' AND id_category = ' . (int)$this-&gt;id_category_default);
	}

</pre>
<p>Once we get that, we can retrieve previous and next products:</p>
<pre class="brush: php; title: ; notranslate">

	public function getAdjacentProducts()
	{


		$position  = Db::getInstance()-&gt;getValue('SELECT position FROM '._DB_PREFIX_.'category_product WHERE id_product = ' . (int)$this-&gt;id . ' AND id_category = ' . (int)$this-&gt;id_category_default);

		// get products that are before and after
		
		$previous = Db::getInstance(_PS_USE_SQL_SLAVE_)-&gt;getRow('
			SELECT cp.id_product, pl.link_rewrite, cp.position, pl.name
			FROM '._DB_PREFIX_.'category_product cp
			LEFT JOIN '._DB_PREFIX_.'product_lang pl ON (cp.id_product = pl.id_product)
			LEFT JOIN '._DB_PREFIX_.'product p ON (cp.id_product = p.id_product)
			WHERE p.id_category_default = '.(int)$this-&gt;id_category_default.' AND (cp.position &lt; '. (int)($position ) .' ) AND cp.id_category = ' . (int)$this-&gt;id_category_default .' AND pl.id_lang = '.(Context::getContext()-&gt;language-&gt;id).'
			ORDER BY cp.position DESC');

		$next = Db::getInstance(_PS_USE_SQL_SLAVE_)-&gt;getRow('
			SELECT cp.id_product, pl.link_rewrite, cp.position, pl.name
			FROM '._DB_PREFIX_.'category_product cp
			LEFT JOIN '._DB_PREFIX_.'product_lang pl ON (cp.id_product = pl.id_product)
			LEFT JOIN '._DB_PREFIX_.'product p ON (cp.id_product = p.id_product)
			WHERE p.id_category_default = '.(int)$this-&gt;id_category_default.' AND (cp.position &gt; '. (int)($position ) .' ) AND cp.id_category = ' . (int)$this-&gt;id_category_default .' AND pl.id_lang = '.(Context::getContext()-&gt;language-&gt;id).'
			ORDER BY cp.position ASC');


		return array('previous' =&gt; $previous, 'next' =&gt; $next);
	}


</pre>
<p><strong>Explanation:</strong> We are using basically the same qurery for both the previous and next product. For the previous, we get the very first product that has a lower position, given the conditions. For the next, the one that has the immediately higher one. Notice we only grab products from the same default category, and that is why we can&#8217;t simply use position + 1 and position &#8211; 1 in a single query (we would have gaps)</p>
<div class="separator"></div>
<h2>Step 2 &#8211; Assigning products to the Product page</h2>
<p>It&#8217;s time to assign the variables we got to the product page. Create a new override, this time inside <em>override/controllers/front</em> and call it <strong>ProductController.php</strong>. Then, as always, initialize the class override:</p>
<pre class="brush: php; title: ; notranslate">


Class ProductController extends ProductControllerCore
{

	public function initContent()
	{
	
		parent::initContent();
	}	
}
</pre>
<p>We are going to extend the initContent() method, as you can see. Therefore, inside it, and before calling the parent&#8217;s initContent(), paste the following:</p>
<pre class="brush: php; title: ; notranslate">


		$adjacent_products = $this-&gt;product-&gt;getAdjacentProducts();

		$this-&gt;context-&gt;smarty-&gt;assign(array(
			'prev_product'=&gt; $adjacent_products['previous'],
			'next_product'=&gt; $adjacent_products['next']
		));


</pre>
<p><strong>Explanation:</strong> Nothing special here, we simply use the previously created method, and then assign previous and next products</p>
<p>Our final override should look like this:</p>
<pre class="brush: php; title: ; notranslate">
Class ProductController extends ProductControllerCore
{

	public function initContent()
	{


		$adjacent_products = $this-&gt;product-&gt;getAdjacentProducts();

		$this-&gt;context-&gt;smarty-&gt;assign(array(
			'prev_product'=&gt; $adjacent_products['previous'],
			'next_product'=&gt; $adjacent_products['next']
		));

		parent::initContent();
	}	
}
</pre>
<p>Time to add our buttons! Before that, though, open the <em>cache/</em> folder and <strong>erase class_index.php</strong> so that our overrides can take place!</p>
<div class="separator"></div>
<h2>Step 3 &#8211; Adding the new buttons to product.tpl</h2>
<p>In this last stepm I will use the default template (as always), so your code might differ from mine, especially if you are using Prestashop 1.5, as I am using 1.6.</p>
<p>We first need to decide where the two buttons are going to sit. Ideally, I recommend adding them at the very top of the product page, so that they are easily and immediately accessible. Of course, any place is fine. Once you decide on position, open up <strong>product.tpl</strong> located in your theme&#8217;s folder.</p>
<p>For my position, the right spot is <strong>immediately before</strong> the following code, at the very beginning of the file:</p>
<pre class="brush: xml; title: ; notranslate">
	&lt;div class=&quot;primary_block row&quot;&gt;
</pre>
<p>Paste the following in:</p>
<pre class="brush: php; html-script: true; title: ; notranslate">
&lt;!-- Navigation --&gt;

&lt;div class=&quot;product-navigation clearfix&quot; style=&quot;margin-bottom:20px&quot;&gt;
	{if $prev_product}
		&lt;a title=&quot;{$prev_product.name}&quot; class=&quot;btn btn-default&quot; href=&quot;{$link-&gt;getProductLink($prev_product.id_product, $prev_product.link_rewrite)}&quot;&gt;{l s='Previous Product'}&lt;/a&gt;
	{/if}
	{if $next_product}
		&lt;a title=&quot;{$next_product.name}&quot; class=&quot;btn btn-default&quot; style=&quot;float:right&quot;href=&quot;{$link-&gt;getProductLink($next_product.id_product, $next_product.link_rewrite)}&quot;&gt;{l s='Next Product'}&lt;/a&gt;
	{/if}
&lt;/div&gt;

</pre>
<p>And we are done!</p>
<p><a href="http://nemops.com/wp-content/uploads/2014/09/prevnext_tut.png"><img src="http://nemops.com/wp-content/uploads/2014/09/prevnext_tut-680x194.png" alt="Display previous and next navigation buttons in the product page in prestashop" width="680" height="194" class="aligncenter size-large wp-image-2165" /></a></p>
<p>The post <a rel="nofollow" href="http://nemops.com/prestashop-previous-next-product-buttons/">Adding Previous and Next navigation buttons to the Prestashop product page</a> appeared first on <a rel="nofollow" href="http://nemops.com">NemoPS</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://nemops.com/prestashop-previous-next-product-buttons/feed/</wfw:commentRss>
		<slash:comments>19</slash:comments>
		</item>
	</channel>
</rss>
