<?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; links</title>
	<atom:link href="https://nemops.com/tag/links/feed/" rel="self" type="application/rss+xml" />
	<link>https://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>Prestashop Redirections</title>
		<link>https://nemops.com/prestashop-redirections/</link>
		<comments>https://nemops.com/prestashop-redirections/#comments</comments>
		<pubDate>Mon, 30 Mar 2015 09:14:43 +0000</pubDate>
		<dc:creator><![CDATA[Nemo]]></dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[links]]></category>
		<category><![CDATA[prestashop]]></category>
		<category><![CDATA[redirection]]></category>

		<guid isPermaLink="false">http://nemops.com/?p=2357</guid>
		<description><![CDATA[<p>In this flash tip we will see how to deal with Prestashop redirections in the cleanest possible way, and send customers where we want after login as well. Redirecting in Prestashop Using normal redirections with the php header method in Prestashop is highly not recommended. Instead, Prestashop has its own methods to redirect users to [&#8230;]</p>
<p>The post <a rel="nofollow" href="https://nemops.com/prestashop-redirections/">Prestashop Redirections</a> appeared first on <a rel="nofollow" href="https://nemops.com">NemoPS</a>.</p>
]]></description>
				<content:encoded><![CDATA[<p>In this flash tip we will see how to deal with Prestashop redirections in the cleanest possible way, and send customers where we want after login as well.</p>
<p><span id="more-2357"></span></p>
<h2>Redirecting in Prestashop</h2>
<p>Using normal redirections with the php <strong>header</strong> method in Prestashop is highly not recommended. Instead, Prestashop has its own methods to redirect users to the page you want, specifically for the front and back office.</p>
<div class="separator"></div>
<h2>Redirecting users in the Front office after login</h2>
<p>We can use two methods to manage Prestashop Redirections in the front office:</p>
<ul>
<li>Tools::redirect($url)</li>
<li>Tools::redirectLink($url)</li>
</ul>
<p>The first one is what I generally use:</p>
<pre class="brush: php; title: ; notranslate">
Tools::redirect('order');
</pre>
<p><strong>redirectLink</strong>can be used the same way. However, the previous one also allows us to use a custom base url, a link class and custom headers:</p>
<pre class="brush: php; title: ; notranslate">
Tools::redirect($url, $base_uri = __PS_BASE_URI__, Link $link = null, $headers = null)
</pre>
<p>They are generally not needed, but might come in handy for specific cases. If you only use the page name, like I used <strong>order</strong> above, make sure it exists within the shop. Therefore, something like the following will not work (unless you really setup a specific htaccess rule for it)</p>
<pre class="brush: php; title: ; notranslate">
Tools::redirect('ordersomethingelse');
</pre>
<p>And you will end up with a 404 page</p>
<p>Knowing that, let&#8217;s see how to redirect our users to a custom page after logging in. We will not use overrides to be quicker.</p>
<p>Open up <strong>AuthController.php</strong> located in <em>controllers/front</em>. Locate the following, around line 620:</p>
<pre class="brush: php; title: ; notranslate">
if (($back = Tools::getValue('back')) &amp;&amp; $back == Tools::secureReferrer($back))
	Tools::redirect(html_entity_decode($back));

// redirection: if cart is not empty : redirection to the cart
				if (!$this-&gt;ajax &amp;&amp; $back = Tools::getValue('back'))
				{
					if ($back == Tools::secureReferrer(Tools::getValue('back')))
						Tools::redirect(html_entity_decode($back));

					$back = $back ? $back : 'my-account';
					Tools::redirect('index.php?controller='.(($this-&gt;authRedirection !== false) ? urlencode($this-&gt;authRedirection) : $back));
				}
</pre>
<p>We can get rid of most of it as we really want users to reach our custom page (in this case, a product)</p>
<pre class="brush: php; title: ; notranslate">

				if (!$this-&gt;ajax)
				{
					Tools::redirect('index.php?controller=product&amp;id_product=1');
				}
</pre>
<p>This, will, no matter what, send users to that product&#8217;s page when they login</p>
<div class="separator"></div>
<h2>Prestashop redirection in the Back Office</h2>
<p>To redirect to a page of the admin interface, it will be enough to use the following</p>
<pre class="brush: php; title: ; notranslate">
Tools::redirectAdmin($url);
</pre>
<p>However, retrieving the url might be a bit troublesome since Prestashop uses a token to secure back office pages. In this case, we first need to grab the url as follows:</p>
<pre class="brush: php; title: ; notranslate">
		$link = $this-&gt;context-&gt;link-&gt;getAdminLink('AdminProducts');
		Tools::redirectAdmin($link);
</pre>
<p>$link will contain the needed token so that your back office page won&#8217;t crash to an &#8220;invalid token&#8221; error.</p>
<div class="separator"></div>
<h2>Always retrieving correct links</h2>
<p>Here is a list of methods you can use to retrieve various entities&#8217; links in Prestashop <strong>(please make sure you use the correct context)</strong>:</p>
<pre class="brush: php; title: ; notranslate">
// page link, like 'index', 'order'...
$this-&gt;context-&gt;link-&gt;getPagelink('pagename')
// CMS page link, first parameter being the cms id
$this-&gt;context-&gt;link-&gt;getPagelink(9)
// Various entities, with id as the parameter
$this-&gt;context-&gt;link-&gt;getSupplierLink(9)
$this-&gt;context-&gt;link-&gt;getManufacturerLink(9)
$this-&gt;context-&gt;link-&gt;getProductLink(9)
$this-&gt;context-&gt;link-&gt;getCategoryLink(9)
// Modules, with parameters like ('modulename', 'controller', array(1,2,3)), the array being a list of querystring parameters
$this-&gt;context-&gt;link-&gt;getModuleLink('psticket', 'mytickets', array('id_ticket' =&gt; 1, 'example' =&gt; 1))

</pre>
<p>The post <a rel="nofollow" href="https://nemops.com/prestashop-redirections/">Prestashop Redirections</a> appeared first on <a rel="nofollow" href="https://nemops.com">NemoPS</a>.</p>
]]></content:encoded>
			<wfw:commentRss>https://nemops.com/prestashop-redirections/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>New Free Prestashop Module: Header Links!</title>
		<link>https://nemops.com/new-free-prestashop-module-header-links/</link>
		<comments>https://nemops.com/new-free-prestashop-module-header-links/#comments</comments>
		<pubDate>Thu, 07 Nov 2013 09:07:21 +0000</pubDate>
		<dc:creator><![CDATA[Nemo]]></dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[free module]]></category>
		<category><![CDATA[links]]></category>
		<category><![CDATA[prestashop]]></category>

		<guid isPermaLink="false">http://nemops.com/?p=1671</guid>
		<description><![CDATA[<p>A new and free Prestashop Module is available at my addons store! It&#8217;s called Header Links, and you can use it to add translatable links to the header of your webstore. Download the Free Module at the Addons Store! Configurable Header links is a highly customizable, free Prestashop Module that you can use to add fully [&#8230;]</p>
<p>The post <a rel="nofollow" href="https://nemops.com/new-free-prestashop-module-header-links/">New Free Prestashop Module: Header Links!</a> appeared first on <a rel="nofollow" href="https://nemops.com">NemoPS</a>.</p>
]]></description>
				<content:encoded><![CDATA[<p>A new and free Prestashop Module is available at my addons store! It&#8217;s called Header Links, and you can use it to add translatable links to the header of your webstore.</p>
<p><span id="more-1671"></span></p>
<p><a title="Free Prestashop Module: Header Links" href="http://store.nemops.com/free-modules/30-prestashop-header-links.html">Download the Free Module at the Addons Store!</a></p>
<p>Configurable Header links is a highly customizable, free Prestashop Module that you can use to add <strong>fully translatable </strong>links to your webstore&#8217;s header. Therefore, it&#8217;s absolutely ideal for who needs to have links pointing to different pages for each language!</p>
<p>Need more flexibility? By editing the included css file, you can also use this module as a custom top menu (without dropdowns)</p>
<h3>Core Features</h3>
<ul>
<li>Absolutely FREE!</li>
<li>Plug and play</li>
<li>Choose a link text, url and title tag for each language of your store!</li>
</ul>
<p>The post <a rel="nofollow" href="https://nemops.com/new-free-prestashop-module-header-links/">New Free Prestashop Module: Header Links!</a> appeared first on <a rel="nofollow" href="https://nemops.com">NemoPS</a>.</p>
]]></content:encoded>
			<wfw:commentRss>https://nemops.com/new-free-prestashop-module-header-links/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
