<?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; smarty</title>
	<atom:link href="http://nemops.com/tag/smarty/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>Essential Prestashop Functions – Day 5</title>
		<link>http://nemops.com/prestashop-functions-5/</link>
		<comments>http://nemops.com/prestashop-functions-5/#comments</comments>
		<pubDate>Tue, 08 Sep 2015 08:40:16 +0000</pubDate>
		<dc:creator><![CDATA[Nemo]]></dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[functions]]></category>
		<category><![CDATA[prestashop]]></category>
		<category><![CDATA[smarty]]></category>
		<category><![CDATA[template]]></category>

		<guid isPermaLink="false">http://nemops.com/?p=2522</guid>
		<description><![CDATA[<p>Prestashop has lots of time-saving functions that we can use when developing modules or extensions. In today&#8217;s batch, we will examine template level functions. Assigning variables to smarty from PHP Creating translatable strings These are to be used whenever you want to create a translatable string in a template. After adding them, you can reach [&#8230;]</p>
<p>The post <a rel="nofollow" href="http://nemops.com/prestashop-functions-5/">Essential Prestashop Functions – Day 5</a> appeared first on <a rel="nofollow" href="http://nemops.com">NemoPS</a>.</p>
]]></description>
				<content:encoded><![CDATA[<p>Prestashop has lots of time-saving functions that we can use when developing modules or extensions. In today&#8217;s batch, we will examine template level functions.</p>
<p><span id="more-2522"></span></p>
<h2>Assigning variables to smarty from PHP</h2>
<pre class="brush: php; title: ; notranslate">

$this-&gt;context-&gt;smarty-&gt;assign('variablenameinsmarty', $myvalue); // you will be able to access this as {$variablenameinsmarty} in the template

// same as above, but in batch
$this-&gt;context-&gt;smarty-&gt;assign(array(
	'variablenameinsmarty' =&gt; $myvalue,
	'anothervariablenameinsmarty' =&gt; $myothervalue,
));

</pre>
<div class="separator"></div>
<h2>Creating translatable strings</h2>
<pre class="brush: php; html-script: true; title: ; notranslate">

{l s='This is my string'} // theme template
{l s='This is my string' mod='modulename'}// module template
{l s='There are %s errors' sprintf=[$account_error|@count]} // theme template with variable replacement
{l s='No file selected' js=1} // supposed to be used in a javascript script, only within addJsDef (see below)
{l s='Billing Address' pdf='true'} // only used within PDF templates
</pre>
<p>These are to be used whenever you want to create a translatable string in a template. After adding them, you can reach out the translations page in the back office and add them into other languages. &#8220;mod&#8221; ones will be found under &#8220;Installed Modules Translations&#8221;; &#8220;pdf&#8221; ones under PDF Translations; theme ones under Front Office Translations, choosing the specific template.</p>
<div class="separator"></div>
<h2>Adding javascript variable definitions</h2>
<pre class="brush: php; html-script: true; title: ; notranslate">

{addJsDef wishlistProductsIds=$wishlist_products}

{addJsDef mySliderCount=7}

{addJsDefL name='youhavelides'}{l s='You save Slides!' js=1}{/addJsDefL}

</pre>
<p>These are needed when you want to pass data from the template to any attached .js file. You will have to make sure to write any script inside a jquery ready statement if you load them in the header, or variables won&#8217;t be readily available. Notice how the first one uses the javascript variable name, while the language one sets it using name=&#8221;.</p>
<h3>Example Usage</h3>
<pre class="brush: jscript; title: ; notranslate">
// will alert &quot;You have slides!&quot; in the current language
if(mySliderCount &gt; 0)
	alert(youhavelides);

</pre>
<div class="separator"></div>
<h2>Displaying a formatted price</h2>
<pre class="brush: php; html-script: true; title: ; notranslate">

{convertPrice price=$price} // display Price in the current currency
{displayPrice price=$price currency=$id_currency} // specify the currency
</pre>
<p>These are used to format the price only. They will not take care of any conversion rate, even if the first one is named that way.</p>
<h3>Example Usage</h3>
<pre class="brush: php; html-script: true; title: ; notranslate">

// default currency is $, id 2 is Euros
{convertPrice price=1} // $1.00
{displayPrice price=1 currency=2} // 1,00 €

</pre>
<div class="separator"></div>
<h2>Displaying a formatted date</h2>
<pre class="brush: php; html-script: true; title: ; notranslate">

{dateFormat date=$date full =1} // display a date formatted like specified in the back office

</pre>
<h3>Example Usage</h3>
<pre class="brush: php; html-script: true; title: ; notranslate">

// chosen date format is dd/mm/yyyy H:i
{dateFormat date=&quot;2015-01-07 22:45:01&quot; } // 07/01/2015
{dateFormat date=&quot;2015-01-07 22:45:01&quot; full=1} // 07/01/2015 22:45

</pre>
<div class="separator"></div>
<h2>Getting a page Link</h2>
<pre class="brush: php; html-script: true; title: ; notranslate">

{$link-&gt;getPageLink('pagename', ssl, id_lang, &quot;GET string or Array&quot;)}

</pre>
<h3>Example Usage</h3>
<pre class="brush: php; html-script: true; title: ; notranslate">

// Gets a link for step 3 of the order process, with ssl
{$link-&gt;getPageLink('order', true, NULL, &quot;step=3&quot;)}

// link to the contact us page
&lt;a href=&quot;{$link-&gt;getPageLink('contact'}&quot; title=&quot;{l s='Contact us'}&quot;&gt;{l s='Contact us'}&lt;/a&gt;

</pre>
<div class="separator"></div>
<h2>Getting a Product Image</h2>
<pre class="brush: php; html-script: true; title: ; notranslate">

{$link-&gt;getImageLink(link_rewrite, id_image, 'image_type')}

</pre>
<h3>Example Usage</h3>
<pre class="brush: php; html-script: true; title: ; notranslate">

// gets the home_default image type, having a product as array
&lt;img src=&quot;{$link-&gt;getImageLink($product.link_rewrite, $product.id_image, 'home_default')}&quot;/&gt;

</pre>
<div class="separator"></div>
<h2>Adding a new hook</h2>
<pre class="brush: php; html-script: true; title: ; notranslate">

{hook h='displaySomething'} // will process any hookDisplaySomething method
{hook h='displaySomething' parameter='my string'} // will pass a variable named &quot;parameter&quot; with value &quot;my string&quot; later available using &quot;params['mystring']&quot; in the hook method

</pre>
<div class="separator"></div>
<h2>Conclusion</h2>
<p>This batch concludes our series on Useful Prestashop Functions. Bear in mind logic should be kept off the templates as much as possible, to preserve the MVC pattern (Prestashop is heading towards it with Prestashop 1.7 removing plenty of modifiers next year). Therefore, whenever possible, try using the PHP counterpart of these functions, preprocessing the output and only using template for displaying data.</p>
<h3>Additional Resources</h3>
<ul>
<li><a href="http://nemops.com/prestashop-functions-1/#.Vb8upPnzrmg" title="Essential Prestashop Functions – Day 1">Essential Prestashop Functions – Day 1</a></li>
<li><a href="http://nemops.com/prestashop-functions-2/#.Vb9Bxvnzrmg" title="Essential Prestashop Functions – Day 2">Essential Prestashop Functions – Day 2</a></li>
<li><a href="http://nemops.com/prestashop-functions-3/#.Vb9EAPnzrmg" title="Essential Prestashop Functions – Day 3">Essential Prestashop Functions – Day 3</a></li>
<li><a href="http://nemops.com/prestashop-functions-4/#.Ve6ZPhHzrmg" title="Essential Prestashop Functions – Day 4">Essential Prestashop Functions – Day 4</a></li>
</ul>
<p>The post <a rel="nofollow" href="http://nemops.com/prestashop-functions-5/">Essential Prestashop Functions – Day 5</a> appeared first on <a rel="nofollow" href="http://nemops.com">NemoPS</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://nemops.com/prestashop-functions-5/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Flash Tip: fixing the &#8220;Featured products number&#8221; issue in Prestashop 1.5.5</title>
		<link>http://nemops.com/featured-products-number-prestashop/</link>
		<comments>http://nemops.com/featured-products-number-prestashop/#comments</comments>
		<pubDate>Fri, 06 Sep 2013 08:43:18 +0000</pubDate>
		<dc:creator><![CDATA[Nemo]]></dc:creator>
				<category><![CDATA[Tips n Tricks]]></category>
		<category><![CDATA[homefeatured]]></category>
		<category><![CDATA[prestashop]]></category>
		<category><![CDATA[smarty]]></category>

		<guid isPermaLink="false">http://nemops.com/?p=1531</guid>
		<description><![CDATA[<p>Many people reported having problems in displaying a different number of items in the Prestashop Module called &#8216;Featured Products on the homepage&#8217;. Let&#8217;s see how to fix it! For how stubborn this issue seems to be, there is a really quick (thus, the &#8220;Flash&#8221; adjective used in the title!) way to solve it. If you [&#8230;]</p>
<p>The post <a rel="nofollow" href="http://nemops.com/featured-products-number-prestashop/">Flash Tip: fixing the &#8220;Featured products number&#8221; issue in Prestashop 1.5.5</a> appeared first on <a rel="nofollow" href="http://nemops.com">NemoPS</a>.</p>
]]></description>
				<content:encoded><![CDATA[<p>Many people reported having problems in displaying a different number of items in the Prestashop Module called &#8216;Featured Products on the homepage&#8217;. Let&#8217;s see how to fix it!</p>
<p><span id="more-1531"></span></p>
<p>For how stubborn this issue seems to be, there is a really quick (thus, the &#8220;Flash&#8221; adjective used in the title!) way to solve it. If you ever come across this kind of issue in Prestashop 1.5.5, go to <strong>Preferences -&gt; Advanced Parameters</strong> and click on <strong>Clear Smarty Cache</strong>.</p>
<p><img class="alignnone size-large wp-image-1532" alt="How to clear Smarty cache for stuck modules" src="http://nemops.com/wp-content/uploads/2013/09/clear_smarty_cache-680x343.png" width="680" height="343" /></p>
<p>That&#8217;s it, refresh the page, done!</p>
<p>The post <a rel="nofollow" href="http://nemops.com/featured-products-number-prestashop/">Flash Tip: fixing the &#8220;Featured products number&#8221; issue in Prestashop 1.5.5</a> appeared first on <a rel="nofollow" href="http://nemops.com">NemoPS</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://nemops.com/featured-products-number-prestashop/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
