<?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; languages</title>
	<atom:link href="http://nemops.com/tag/languages/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>Prestashop 101 Day 16 &#8211; Employees and Languages</title>
		<link>http://nemops.com/prestashop-employees-and-languages/</link>
		<comments>http://nemops.com/prestashop-employees-and-languages/#comments</comments>
		<pubDate>Tue, 09 Jul 2013 09:53:32 +0000</pubDate>
		<dc:creator><![CDATA[Nemo]]></dc:creator>
				<category><![CDATA[Basics]]></category>
		<category><![CDATA[employees]]></category>
		<category><![CDATA[languages]]></category>
		<category><![CDATA[prestashop 101]]></category>

		<guid isPermaLink="false">http://nemops.com/?p=1392</guid>
		<description><![CDATA[<p>Time to expand our business to the rest of the world! But to do this we will need to add other employees and languages to our shop. Luckily, Prestashop saves us the day again providing easy ways to do both things! Running time: 15 mins Prestashop version used: 1.5.4.1 &#160; All series&#8217; lessons Day 1 &#8211; [&#8230;]</p>
<p>The post <a rel="nofollow" href="http://nemops.com/prestashop-employees-and-languages/">Prestashop 101 Day 16 &#8211; Employees and Languages</a> appeared first on <a rel="nofollow" href="http://nemops.com">NemoPS</a>.</p>
]]></description>
				<content:encoded><![CDATA[<p>Time to expand our business to the rest of the world! But to do this we will need to add other employees and languages to our shop. Luckily, Prestashop saves us the day again providing easy ways to do both things!<br />
<span id="more-1392"></span></p>
<p><strong>Running time: </strong>15 mins<br />
<strong>Prestashop version used:</strong> 1.5.4.1</p>
<div class="separator"></div>
<p>&nbsp;</p>
<h3>All series&#8217; lessons</h3>
<ul>
<li><a title="Prestashop 101 Day 1 – Introducing and installing Prestashop" href="http://nemops.com/prestashop-101-day-1-installing-prestashop/">Day 1 &#8211; Introducing and installing Prestashop</a></li>
<li><a title="Prestashop 101 Day 2 – Basic Prestashop Configuration" href="http://nemops.com/prestashop-101-prestashop-configuration/">Day 2 &#8211; Basic Prestashop Configuration</a></li>
<li><a title="Prestashop 101 Day 3 – Prestashop categories and products" href="http://nemops.com/prestashop-categories-and-products/">Day 3 &#8211; Prestashop categories and products</a></li>
<li><a title="Prestashop 101 Day 4 – Prestashop Attributes Combinations" href="http://nemops.com/prestashop-attributes/">Day 4 &#8211; Prestashop Attributes Combinations</a></li>
<li><a title="Prestashop 101 Day 5 – Prestashop Upgrade" href="http://nemops.com/prestashop-upgrade/">Day 5 &#8211; Prestashop Upgrade</a></li>
<li><a title="Prestashop 101 Day 6 – Prestashop Modules" href="http://nemops.com/prestashop-modules/">Day 6 &#8211; Prestashop Modules</a></li>
<li><a title="Prestashop 101 Day 7 – Prestashop Shipping, Zones and Countries" href="http://nemops.com/prestashop-shipping-zones-countries/">Day 7 &#8211; Prestashop Shipping, Zones and Countries</a></li>
<li><a title="Prestashop 101 Day 8 – Taxes, Currencies, Payments" href="http://nemops.com/prestashop-payments-currencies-taxes/">Day 8 &#8211; Taxes, Currencies, Payments</a></li>
<li><a title="Prestashop 101 Day 9 – Order Management" href="http://nemops.com/order-management/">Day 9 &#8211; Order Management</a></li>
<li><a title="Prestashop 101 Day 10 - Prestashop Customers" href="http://nemops.com/prestashop-customers/">Day 10 &#8211; Prestashop Customers</a></li>
<li><a title="Prestashop 101 Day 11 - Prestashop Discounts (Cart rules)" href="http://nemops.com/prestashop-discounts-cart-rules/">Day 11 &#8211; Prestashop Discounts (Cart rules)</a></li>
<li><a title="Prestashop 101 Day 12 - Prestashop Themes and visual tweaks" href="http://nemops.com/prestashop-themes/">Day 12 &#8211; Prestashop Themes and visual tweaks</a> </li>
<li><a title="Prestashop 101 Day 13 - Prestashop CMS" href="http://nemops.com/prestashop-cms/">Day 13 &#8211; Prestashop CMS</a> </li>
<li><a title="Prestashop 101 Day 14 - Prestashop SEO and Preferences" href="http://nemops.com/prestashop-seo-and-preferences/">Day 14 &#8211; Prestashop SEO and Preferences</a> </li>
<li><a title="Prestashop 101 Day 15 - Prestashop Multistore" href="http://nemops.com/prestashop-multistore/">Day 15 &#8211; Prestashop Multistore</a> </li>
<li>Day 16 &#8211; Employees and languages</li>
</ul>
<h2>Watch the screencast</h2>

	<div class="video-embed">
		<iframe width="640" height="360" src="http://www.youtube.com/embed/FqqaTPXzNwY" 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>
<p>The post <a rel="nofollow" href="http://nemops.com/prestashop-employees-and-languages/">Prestashop 101 Day 16 &#8211; Employees and Languages</a> appeared first on <a rel="nofollow" href="http://nemops.com">NemoPS</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://nemops.com/prestashop-employees-and-languages/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Target specific languages with Prestashop Attachments</title>
		<link>http://nemops.com/prestashop-attachments-language/</link>
		<comments>http://nemops.com/prestashop-attachments-language/#comments</comments>
		<pubDate>Fri, 18 Jan 2013 15:18:28 +0000</pubDate>
		<dc:creator><![CDATA[Nemo]]></dc:creator>
				<category><![CDATA[Tips n Tricks]]></category>
		<category><![CDATA[attachments]]></category>
		<category><![CDATA[languages]]></category>
		<category><![CDATA[prestashop]]></category>

		<guid isPermaLink="false">http://nemops.com/?p=929</guid>
		<description><![CDATA[<p>Attachments are a great way to provide your customers with rich pre-sale information about your products. But what if your site is multilingual? Let&#8217;s see how to make Prestashop Attachments language-specific. Version compatibility: Prestashop 1.4, Prestashop 1.5 Introduction So, you have a multilanguage store. And you also offer detailed spreadsheets of your products, or bonus [&#8230;]</p>
<p>The post <a rel="nofollow" href="http://nemops.com/prestashop-attachments-language/">Target specific languages with Prestashop Attachments</a> appeared first on <a rel="nofollow" href="http://nemops.com">NemoPS</a>.</p>
]]></description>
				<content:encoded><![CDATA[<p>Attachments are a great way to provide your customers with rich pre-sale information about your products. But what if your site is multilingual? Let&#8217;s see how to make Prestashop Attachments language-specific.</p>
<p><span id="more-929"></span></p>
<ul>
<li>Version compatibility: <strong>Prestashop 1.4, Prestashop 1.5</strong></li>
</ul>
<h2>Introduction</h2>
<p>So, you have a multilanguage store. And you also offer detailed spreadsheets of your products, or bonus videos, as downloadable attachments in product pages. There is a problem though: Prestashop doesn&#8217;t come with a way of targeting specific languages when adding attachments (even though the attachment name is translatable). How to cope with it, in case your attachments are really language-specific? With a little trick, we will take advantage of the default variables assigned to a product page and only display specific downloadable files.</p>
<div class="separator"></div>
<h2>Step 1 &#8211; Adding attachments</h2>
<p>The first, and most important step is, of course, to add attachments to your products. I will use a demo product, the iPod Nano that comes out of the box with Prestashop. I will also make use of Prestashop 1.5 for this, even though the process can be applied in the same way with 1.4.</p>
<p>Fire up your admin panel and go to <em>Catalog &gt; Attachments</em> (last link). Click on <strong>Add new</strong> in the top right corner</p>
<p>Here is the little secret: we will append the <strong>iso code</strong> for our language to the name of the attachment, so that it can be then targeted in the template. Let&#8217;s call our file <strong>demo_en</strong>. Don&#8217;t worry for the bad look it has, we will remove the useless part when displaying links. Add a description if you want (it&#8217;s not mandatory), and choose a file to upload. When you&#8217;re done, click <em>Save</em>. Note that the actual name of the file doesn&#8217;t matter at all, <strong>the important part is the attachment name</strong>. If you don&#8217;t know the iso code for your language, head over to <em>Localization &gt; Languages</em>, and check the column highlighted in the following image:</p>
<div id="attachment_936" style="width: 690px" class="wp-caption aligncenter"><a href="http://nemops.com/wp-content/uploads/2013/01/Languages_iso.png"><img class="size-large wp-image-936" alt="Prestashop Languages Tab" src="http://nemops.com/wp-content/uploads/2013/01/Languages_iso-680x384.png" width="680" height="384" /></a><p class="wp-caption-text">Prestashop Languages Tab</p></div>
<div class="separator"></div>
<h2>Step 2 &#8211; Attaching our file to the product</h2>
<p>Ok, we have our file, it&#8217;s time to add it to one of our products. Head over to a product page in the back office (I chose iPod Nano), and click on the <strong>Attachments</strong> tab in the left column. Here is what it&#8217;ll look like:</p>
<p><div id="attachment_937" style="width: 690px" class="wp-caption aligncenter"><a href="http://nemops.com/wp-content/uploads/2013/01/product_attachments.png"><img class="size-large wp-image-937" alt="Prestashop Product Attachments" src="http://nemops.com/wp-content/uploads/2013/01/product_attachments-680x613.png" width="680" height="613" /></a><p class="wp-caption-text">Prestashop Product Attachments</p></div><br />
&nbsp;<br />
See the highlighted area? It displays attachments which are currently added to a product. It&#8217;s empty in my case, and I can see the attachment I just created is available in the left hand box. Select it, and click <strong>Add &gt;&gt;</strong> just below the box. <strong>Be sure you save the product now</strong>, otherwise the attachment won&#8217;t be added. If you successfully did this, after the refresh you should see the attachment appearing in the right hand box.<br />
<strong>Note:</strong> You will see that you can also add attachments from this page. if you do, they&#8217;ll automatically be linked to this product, without having to add them from the left box.</p>
<div class="separator"></div>
<h2>Step 3 &#8211; Adding the language-specific logic</h2>
<p>Now that the attachment has been sticked to our product, let&#8217;s head for the front office and check it out. Here it is:</p>
<div id="attachment_938" style="width: 555px" class="wp-caption aligncenter"><a href="http://nemops.com/wp-content/uploads/2013/01/attachment.png"><img class="size-full wp-image-938" alt="Prestashop Attachments in product page" src="http://nemops.com/wp-content/uploads/2013/01/attachment.png" width="545" height="212" /></a><p class="wp-caption-text">Prestashop Attachments in product page</p></div>
<p>&nbsp;</p>
<p>Of course, it will be displayed for every language at this stage. Locate your theme folder, and open up <strong>product.tpl</strong> in your favorite code editor. We will be editing the attachments portion of this file to only display our languaged file.</p>
<p>Locate the following code (Prestashop 1.5.3 &#8211; at about line 518):</p>
<pre class="brush: php; title: ; notranslate">
		{if isset($attachments) &amp;&amp; $attachments}
</pre>
<p>If you&#8217;re on Prestashop 1.4, it will be more like this (default template)</p>
<pre class="brush:php">
		{if $attachments}
</pre>
<p>You will have the following block inside the condition:</p>
<pre class="brush: php; title: ; notranslate">
	&lt;ul id=&quot;idTab9&quot; class=&quot;bullet&quot;&gt;
	{foreach from=$attachments item=attachment}
		&lt;li&gt;&lt;a href=&quot;{$link-&gt;getPageLink('attachment', true, NULL, &quot;id_attachment={$attachment.id_attachment}&quot;)}&quot;&gt;{$attachment.name|escape:'htmlall':'UTF-8'}&lt;/a&gt;&lt;br /&gt;{$attachment.description|escape:'htmlall':'UTF-8'}&lt;/li&gt;
	{/foreach}
	&lt;/ul&gt;	
</pre>
<p>Let&#8217;s start amending it to add some language logic, add this just after the div&#8217;s opening:</p>
<pre class="brush: php; title: ; notranslate">
	{$lang_checker = {&quot;_&quot;|cat:{$lang_iso}}}
	{foreach from=$languages item=language} 
		{$lang_checker_array[] = {&quot;_&quot;|cat:{$language.iso_code}}}
	{/foreach}	
</pre>
<p><strong>Explanation:</strong> We are taking advantage of 2 variables here. First, we create a <em>$lang_checker</em> variable, consisting of an underscore plus the iso code of the current language of the store (this will help us target it in the attachment name); then, we create an array with all the languages&#8217; iso codes, and as before, they&#8217;re prepended of an underscore. You can actually use any special character here, but you&#8217;ll of course need to be consitent with attachment names if you want to do it.</p>
<p>Now, amend the foreach statement as follows:</p>
<pre class="brush: php; title: ; notranslate">
{foreach from=$attachments item=attachment}
	{if $attachment.name|strstr:{$lang_checker}}
			&lt;li&gt;&lt;a href=&quot;{$link-&gt;getPageLink('attachment', true, NULL, &quot;id_attachment={$attachment.id_attachment}&quot;)}&quot;&gt;{$attachment.name|escape:'htmlall':'UTF-8'|replace:{$lang_checker}:''}&lt;/a&gt;&lt;br /&gt;{$attachment.description|escape:'htmlall':'UTF-8'}&lt;/li&gt;			
	{/if}
{/foreach}	
</pre>
<p>Refresh the page. You won&#8217;t see changes if your current language is the same as the attachment&#8217;s one, otherwise, you&#8217;ll notice the attachment is gone! Yep, that&#8217;s it, we are only displaying the attchment if it contains the actual iso code. We are also replacing (<strong>|replace:{$lang_checker}:&#8221;</strong>) the iso so that it&#8217;s removed from the name. <strong>Sweet</strong>.</p>
<p><strong>Note:</strong> on Prestashop 1.4, the getPageLink must refer to <strong>attachment.php</strong>, not only <em>attachment</em>.</p>
<p>And we could stop here, careless of future implementation. But we are smart. The code needs to be more robust in case we change our mind and want to display some attachments to all the audience. At the moment, those ones would not be displayed due to our language restriction.</p>
<div class="separator"></div>
<h2>Step 4 &#8211; Fallback for non-languaged downloads</h2>
<p>Add another attachment to this product, but this time <strong>don&#8217;t append any iso code</strong>. If you refresh the product page, you won&#8217;t be able to see the new attachment, of course. Let&#8217;s amend our previous code the following way:</p>
<pre class="brush:php">
{if isset($attachments) &#038;&#038; $attachments}
	<ul id="idTab9" class="bullet">
	{$lang_checker = {"_"|cat:{$lang_iso}}}
	{foreach from=$languages item=language} 
		{$lang_checker_array[] = {"_"|cat:{$language.iso_code}}}
	{/foreach}			
	{foreach from=$attachments item=attachment}
		{if $attachment.name|strstr:{$lang_checker}}
				<li><a href="{$link->getPageLink('attachment', true, NULL, "id_attachment={$attachment.id_attachment}")}">{$attachment.name|escape:'htmlall':'UTF-8'|replace:{$lang_checker}:''}</a><br />{$attachment.description|escape:'htmlall':'UTF-8'}</li>	
		{else}	
			{$denier = false}
			{foreach from=$lang_checker_array item=checkr_lang}
				{if $attachment.name|strstr:{$checkr_lang}} <!-- Means we found it, don't add to the list -->
					{$denier = true}
				{/if}		
			{/foreach}
			{if !$denier}
				<li><a href="{$link->getPageLink('attachment', true)}?id_attachment={$attachment.id_attachment}">{$attachment.name|escape:'htmlall':'UTF-8'}</a><br />{$attachment.description|escape:'htmlall':'UTF-8'}</li>
			{/if}									
		{/if}
	{/foreach}
	</ul>
{/if}	
</pre>
<p><strong>Explanation:</strong> A bit messy, but don&#8217;t be afraid. We added an <strong>else</strong> condition in case the iso code pattern is not found in the name. Inside it, we first setup a variable to check whether the file name contains <strong>any</strong> of the store languages&#8217; iso codes. Remember we created an array with all the store languages before? it&#8217;s time to use it; the following iterates through it, and, if one of the languages matches, it sets $denier to true.</p>
<pre class="brush:php">
	{$denier = false}
	{foreach from=$lang_checker_array item=checkr_lang}
		{if $attachment.name|strstr:{$checkr_lang}} <!-- Means we found it, don't add to the list -->
			{$denier = true}
		{/if}		
	{/foreach}
</pre>
<p>So basically we&#8217;re tellng the Prestashop: <em>&#8220;If the file is setup to target a specific language, set $denier to true.&#8221;</em>. The next line shows how to make proficient use of our $denier variable:</p
	></p>
<pre class="brush:php">
		{if !$denier}
			<li><a href="{$link->getPageLink('attachment', true)}?id_attachment={$attachment.id_attachment}">{$attachment.name|escape:'htmlall':'UTF-8'}</a><br />{$attachment.description|escape:'htmlall':'UTF-8'}</li>
		{/if}	
</pre>
<p>If $denier is not set (read: <em>if this file is not configured to target a specific language</em>) add it to the list. Save&amp;Refresh.</p>
<p>The non-language file is now added to the list!</p>
<div class="separator"></div>
<h2>Conclusion</h2>
<p>And that&#8217;s it, you can now play around with different iso codes and see they will always show up the correct way. Of course, there are better way to implement such feature, like editing core files to make it seamless with Prestashop. Nonetheless, this is a cleaver way to achieve the result without heavy core modifications.</p>
<p>The post <a rel="nofollow" href="http://nemops.com/prestashop-attachments-language/">Target specific languages with Prestashop Attachments</a> appeared first on <a rel="nofollow" href="http://nemops.com">NemoPS</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://nemops.com/prestashop-attachments-language/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
