<?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; columns</title>
	<atom:link href="http://nemops.com/tag/columns/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>Hook the Prestashop Layered Navigation Block to the Center Column</title>
		<link>http://nemops.com/prestashop-layered-navigation-block-center-column/</link>
		<comments>http://nemops.com/prestashop-layered-navigation-block-center-column/#comments</comments>
		<pubDate>Wed, 11 Feb 2015 09:05:46 +0000</pubDate>
		<dc:creator><![CDATA[Nemo]]></dc:creator>
				<category><![CDATA[Theming]]></category>
		<category><![CDATA[blocklayered]]></category>
		<category><![CDATA[columns]]></category>

		<guid isPermaLink="false">http://nemops.com/?p=2319</guid>
		<description><![CDATA[<p>Being one of the most frequently asked questions on the official board, in this quick tip we will see how to hook the layered navigation module to the center column, above the product list/grid in Prestashop. Step 1: overriding the Layered Navigation Module (Optional &#8211; 1.6.0.11 and newer only) If you are not using the [&#8230;]</p>
<p>The post <a rel="nofollow" href="http://nemops.com/prestashop-layered-navigation-block-center-column/">Hook the Prestashop Layered Navigation Block to the Center Column</a> appeared first on <a rel="nofollow" href="http://nemops.com">NemoPS</a>.</p>
]]></description>
				<content:encoded><![CDATA[<p>Being one of the most frequently asked questions on the official board, in this quick tip we will see how to hook the layered navigation module to the center column, above the product list/grid in Prestashop.</p>
<p><span id="more-2319"></span></p>
<h2>Step 1: overriding the Layered Navigation Module (Optional &#8211; 1.6.0.11 and newer only)</h2>
<p>If you are not using the latest Prestashop version, you can jump to step 2 as module overrides were not available before that, and it&#8217;s necessary to amend the module directly. If you are, reach the <em>override/modules/</em> folder and create a new one inside it called <strong>blocklayered</strong>. Inside that, add a file named <strong>blocklayered.php</strong> and paste the following inside php tags:</p>
<pre class="brush: php; title: ; notranslate">
 
if (!defined('_CAN_LOAD_FILES_'))
    exit;
 
class BlockLayeredOverride extends BlockLayered
{
 
 
}
</pre>
<p>We have just setup the base file for the override. Go ahead and erase the <strong>class_index.php</strong> located in the <em>cache/</em> folder, so that the new file is loaded and we can start extending the module.</p>
<div class="separator"></div>
<h2>Step 2 &#8211; Adding code for a new hook</h2>
<p>It&#8217;s given that no hook sits on top of the product listing, if you are using, like me, the default template. If you are not, you might want to check out the <strong>category.tpl</strong> file for any usable spot, to avoid adding another one.</p>
<p>We need to add a few lines of code to register a new hook, and allow the Layered Navigation block to stick there as well. First off, if you are using the override method, simply add the following to our new file:</p>
<pre class="brush: php; title: ; notranslate">
 
	public function install()
	{
		if(parent::install() &amp;&amp; $this-&gt;registerHook('categoryTop'))
			return true;
		else return false;
	}

</pre>
<p>Else, if you <strong>are not using the override method</strong>, simply amend the original install() of the <strong>blocklayered.php</strong> file, by adding the new hook registration as follows (see the fourth line &#8220;&#038;&#038; $this->registerHook(&#8216;categoryTop&#8217;)&#8221;)</p>
<pre class="brush: php; title: ; notranslate">
	public function install()
	{
		if (parent::install() &amp;&amp; $this-&gt;registerHook('header')
		&amp;&amp; $this-&gt;registerHook('categoryTop')
		&amp;&amp; $this-&gt;registerHook('categoryAddition') &amp;&amp; $this-&gt;registerHook('categoryUpdate') &amp;&amp; $this-&gt;registerHook('attributeGroupForm')
		&amp;&amp; $this-&gt;registerHook('afterSaveAttributeGroup') &amp;&amp; $this-&gt;registerHook('afterDeleteAttributeGroup') &amp;&amp; $this-&gt;registerHook('featureForm')
		&amp;&amp; $this-&gt;registerHook('afterDeleteFeature') &amp;&amp; $this-&gt;registerHook('afterSaveFeature') &amp;&amp; $this-&gt;registerHook('categoryDeletion')
		&amp;&amp; $this-&gt;registerHook('afterSaveProduct') &amp;&amp; $this-&gt;registerHook('productListAssign') &amp;&amp; $this-&gt;registerHook('postProcessAttributeGroup')
		&amp;&amp; $this-&gt;registerHook('postProcessFeature') &amp;&amp; $this-&gt;registerHook('featureValueForm') &amp;&amp; $this-&gt;registerHook('postProcessFeatureValue')
		&amp;&amp; $this-&gt;registerHook('afterDeleteFeatureValue') &amp;&amp; $this-&gt;registerHook('afterSaveFeatureValue') &amp;&amp; $this-&gt;registerHook('attributeForm')
		&amp;&amp; $this-&gt;registerHook('postProcessAttribute') &amp;&amp; $this-&gt;registerHook('afterDeleteAttribute') &amp;&amp; $this-&gt;registerHook('afterSaveAttribute'))
		{
			if (version_compare(_PS_VERSION_, '1.6.0', '&gt;=') === true)
			{
				// Hook the module either on the left or right column
				$theme = new Theme(Context::getContext()-&gt;shop-&gt;id_theme);
				if ((!$theme-&gt;default_left_column || !$this-&gt;registerHook('leftColumn'))
					&amp;&amp; (!$theme-&gt;default_right_column || !$this-&gt;registerHook('rightColumn')))
				{
					// If there are no colums implemented by the template, throw an error and uninstall the module
					$this-&gt;_errors[] = $this-&gt;l('This module need to be hooked in a column and your theme does not implement one');
					parent::uninstall();
					return false;
				}
			}
			else
				$this-&gt;registerHook('leftColumn');

			Configuration::updateValue('PS_LAYERED_HIDE_0_VALUES', 1);
			Configuration::updateValue('PS_LAYERED_SHOW_QTIES', 1);
			Configuration::updateValue('PS_LAYERED_FULL_TREE', 1);
			Configuration::updateValue('PS_LAYERED_FILTER_PRICE_USETAX', 1);
			Configuration::updateValue('PS_LAYERED_FILTER_CATEGORY_DEPTH', 1);
			Configuration::updateValue('PS_LAYERED_FILTER_INDEX_QTY', 0);
			Configuration::updateValue('PS_LAYERED_FILTER_INDEX_CDT', 0);
			Configuration::updateValue('PS_LAYERED_FILTER_INDEX_MNF', 0);
			Configuration::updateValue('PS_LAYERED_FILTER_INDEX_CAT', 0);
			Configuration::updateValue('PS_ATTRIBUTE_ANCHOR_SEPARATOR', '-');

			$this-&gt;rebuildLayeredStructure();
			$this-&gt;buildLayeredCategories();

			$products_count = Db::getInstance()-&gt;getValue('SELECT COUNT(*) FROM `'._DB_PREFIX_.'product`');

			if ($products_count &lt; 20000) // Lock template filter creation if too many products
				$this-&gt;rebuildLayeredCache();

			self::installPriceIndexTable();
			$this-&gt;installFriendlyUrlTable();
			$this-&gt;installIndexableAttributeTable();
			$this-&gt;installProductAttributeTable();

			if ($products_count &lt; 5000) // Lock indexation if too many products
			{
				self::fullPricesIndexProcess();
				$this-&gt;indexUrl();
				$this-&gt;indexAttribute();
			}

			return true;
		}
		else
		{
			// Installation failed (or hook registration) =&gt; uninstall the module
			$this-&gt;uninstall();
			return false;
		}
	}
</pre>
<p>Then, simply add the following new hooking method to your blocklayered file (whichever you are modifying)</p>
<pre class="brush: php; title: ; notranslate">
	public function hookCategoryTop($params)
	{
		return $this-&gt;hookLeftColumn($params);
	}
</pre>
<p>Before proceeding further, make sure you actually reset the Layered Navigation module from the modules section of the back office, so it register the new hook (or uninstall, then install again if that doesn&#8217;t work).</p>
<div class="separator"></div>
<p>Adding the new hook to the category.tpl template file</p>
<p>We will be using the <a href="http://nemops.com/adding-hooks-to-prestashop-1-5/#.VNiLjvmjOr0" title="new method to add hooks in Prestashop">new method to add hooks in Prestashop</a>, introduced since version 1.5. Open up the <strong>category.tpl</strong> file of your template, locate a suitable spot and paste the following in:</p>
<pre class="brush: php; html-script: true; title: ; notranslate">
{hook h=&quot;categoryTop&quot;}
</pre>
<p><strong>Tip:</strong> I suggest you do it right after the {if $products} statement, before the product list. Here is where I did it, on a default-bootstrap template on 1.6.0.11:</p>
<pre class="brush: php; html-script: true; title: ; notranslate">
...

{if $products}
            {hook h=&quot;categoryTop&quot;}
			&lt;div class=&quot;content_sortPagiBar clearfix&quot;&gt;
            	&lt;div class=&quot;sortPagiBar clearfix&quot;&gt;
            		{include file=&quot;./product-sort.tpl&quot;}

...

</pre>
<p>Save and test, the module should be popping out in the middle column:</p>
<p><a href="http://nemops.com/wp-content/uploads/2015/02/blocklayered_center_col.png"><img src="http://nemops.com/wp-content/uploads/2015/02/blocklayered_center_col-680x409.png" alt="Hook the Prestashop Layered Navigation Block to the Center Column - hooked" width="680" height="409" class="aligncenter size-large wp-image-2324" /></a></p>
<p><strong>What to do if it doesn&#8217;t?</strong> First, make sure that your template has been recompiled: reach <em>Advanced Parameters > Performance</em> in the back office, and set <strong>Template Compilation</strong> to <strong>Recompile templates if the files have been updated</strong> at least, or even Force Compile. Refresh the Front office afterwards.</p>
<p>If you still don&#8217;t see anything, there might be a typo in the hook you register. Check all names, then try killing the script on the hooking method as follows:</p>
<pre class="brush: php; title: ; notranslate">
	public function hookCategoryTop($params)
	{
		die('I am here!');
		return $this-&gt;hookLeftColumn($params);
	}
</pre>
<p>If you see the page rendering interrupted by the &#8220;I am here&#8221; text, the hook should work, check that blocklayered is properly configured. If not, check, once more, for typos in function names, registrations and calls. If you are using the override and it still won&#8217;t work after clearing cache, switch to core modifications.</p>
<div class="separator"></div>
<h2>Step 3 &#8211; Making it work</h2>
<p>If you try out the module now, having it hooked to both either of the side columns and to the center one, you&#8217;ll be disappointed to notice it won&#8217;t work. Why? A javascript error will be triggered upon click.</p>
<p>To fix it, simply <strong>unhook the Layered Navigation from the side columns, leaving only one instance of it running in the center one</strong>. Reach Modules > positions and look the the module&#8217;s instances in displayLeftColumn and displayRightColumn. Unhook both, just in case.</p>
<div class="separator"></div>
<h2>Beauty Pass</h2>
<p>There is no need to say a huge list of features/attributes/whatever shown at the very top of the product list will force people to scroll down to see products. It&#8217;s therefore better to give the new block some better styling. Open up <strong>themes\default-bootstrap\css\modules\blocklayered\blocklayered.css</strong> (or the one of your template, or create it if it&#8217;s not there). </p>
<p>At the cery end, add:</p>
<pre class="brush: css; title: ; notranslate">
#center_column .layered_filter{
  float:left;
  width: 50%;
}
#center_column .layered_filter:nth-child(2n) {
  clear:left;
}
</pre>
<p>It&#8217;s just some basic styling to shorten the height, but it will give you the right pointer to customize it further.</p>
<p>We&#8217;re done!</p>
<p>The post <a rel="nofollow" href="http://nemops.com/prestashop-layered-navigation-block-center-column/">Hook the Prestashop Layered Navigation Block to the Center Column</a> appeared first on <a rel="nofollow" href="http://nemops.com">NemoPS</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://nemops.com/prestashop-layered-navigation-block-center-column/feed/</wfw:commentRss>
		<slash:comments>20</slash:comments>
		</item>
		<item>
		<title>Specifying the number of columns for each Prestashop page</title>
		<link>http://nemops.com/columns-for-each-prestashop-page/</link>
		<comments>http://nemops.com/columns-for-each-prestashop-page/#comments</comments>
		<pubDate>Tue, 20 Aug 2013 08:13:36 +0000</pubDate>
		<dc:creator><![CDATA[Nemo]]></dc:creator>
				<category><![CDATA[Theming]]></category>
		<category><![CDATA[columns]]></category>
		<category><![CDATA[prestashop]]></category>
		<category><![CDATA[template]]></category>

		<guid isPermaLink="false">http://nemops.com/?p=1496</guid>
		<description><![CDATA[<p>In today&#8217;s tutorial we will see how to specify which columns to show for each page our our prestashop store. The $page_name variable In Prestashop, every page has a name. Okay, sounds ridiculous put in this way. However, it simply means that each page of your Prestashop store has a unique identifier that can help [&#8230;]</p>
<p>The post <a rel="nofollow" href="http://nemops.com/columns-for-each-prestashop-page/">Specifying the number of columns for each Prestashop page</a> appeared first on <a rel="nofollow" href="http://nemops.com">NemoPS</a>.</p>
]]></description>
				<content:encoded><![CDATA[<p>In today&#8217;s tutorial we will see how to specify which columns to show for each page our our prestashop store.</p>
<p><span id="more-1496"></span></p>
<h2>The $page_name variable</h2>
<p>In Prestashop, every page has a name. Okay, sounds ridiculous put in this way. However, it simply means that each page of your Prestashop store has a unique identifier that can help you target that and no other page specifically when you want to modify the template?</p>
<p>It is utterly simple to know the name for each page. Reach the page you want, <strong>hit f12</strong> to bring up the developer console of your browser and inspect the html source. Look for the <body> tag and its ID, that&#8217;s the page&#8217;s name!</p>
<p><img src="http://nemops.com/wp-content/uploads/2013/08/body_id.jpg" alt="Inspect the page name in Prestashop" width="595" height="318" class="aligncenter size-full wp-image-1497" /></p>
<p>If you have a look at <strong>header.tpl</strong>, you&#8217;ll see where that name is pulling from as well:</p>
<pre class="brush: php; html-script: true; title: ; notranslate">
&lt;!-- &lt;body {if isset($page_name)}id=&quot;{$page_name|escape:'htmlall':'UTF-8'}&quot;{/if}  --&gt;

</pre>
<p>Therefore, you can see we can target both the specific page id and use that $page_name variable in the template as well. We can therefore have 2 ways (actually 3, if you considered the mixed one), to bend Prestashop to our needs: hard-editing the tpl files, or targeting the page id from CSS.</p>
<h2>Varying the column layout in Prestashop &#8211; the TPL way</h2>
<p>For this first example, we will see how to remove all columns from the homepage, and leave the left one only in the CMS pages. This TPL-only way has its disadvantages, which we&#8217;ll discover soon enough.</p>
<p>Open your <strong>header.tpl</strong> file, and locate</p>
<pre class="brush: php; html-script: true; title: ; notranslate">
				&lt;div id=&quot;left_column&quot; class=&quot;column grid_2 alpha&quot;&gt;
					{$HOOK_LEFT_COLUMN}
				&lt;/div&gt;
</pre>
<p><strong>Note:</strong> I&#8217;m using the default template, yours might be different.</p>
<p>CHange it as follows</p>
<pre class="brush: php; html-script: true; title: ; notranslate">
				{if $page_name != 'index'}
					&lt;div id=&quot;left_column&quot; class=&quot;column grid_2 alpha&quot;&gt;
						{$HOOK_LEFT_COLUMN}
					&lt;/div&gt;
				{/if}
				
</pre>
<p><strong>Explanation:</strong> it simply means: if this is not the homepage, show me the left column. So, if we are currently viewing the home of our web store, that column won&#8217;t even be rendered. As soon as you refresh your homepage, and that only, your left column will be gone.</p>
<p>Now, we need to consider the center column&#8217;s width. In the default template, columns widths are defined by the so-called Prestashop grid, which is a 9-columns based wireframe system. Thus, if we want the center column to span across the entire site&#8217;s width in the homepage, we need to change its class to grid_9&#8230;but for the index only!</p>
<p>Look for</p>
<pre class="brush: php; html-script: true; title: ; notranslate">
&lt;div id=&quot;center_column&quot; class=&quot; grid_5&quot;&gt;
</pre>
<p>And change it into</p>
<pre class="brush: php; html-script: true; title: ; notranslate">
&lt;div id=&quot;center_column&quot; class=&quot;{if $page_name == 'index'}grid_9{else}grid_5{/if}&quot;&gt;
</pre>
<p>Save&#038;refresh. Your right column will be sent to next line. Again, for the homepage only. If we are not currently seeing the index, our center_column will still have a class of grid_5.</p>
<p>Right away, you can see the first issues that arise with this method. If you have custom modules which are set to a fixed width, or in any case are configured to span across the usual center column width, you&#8217;ll need to edit those too, and take the new with into account. This is also true for the <strong>featured products block</strong> as you can see the fifth element is stuck to the fourth. This happens because there is a variable set in homefeatured.tpl, which takes only 4 items per line. You can change it to account for the new size of course. And indeed, the slider up there needs bigger images!</p>
<p><img src="http://nemops.com/wp-content/uploads/2013/08/tpl-issues-680x480.png" alt="After changing the tpl grid class in Prestashop" width="680" height="480" class="aligncenter size-large wp-image-1498" /></p>
<p>Let&#8217;s get rid of the right column to complete our homepage. Open <strong>footer.tpl</strong> and change</p>
<pre class="brush: php; html-script: true; title: ; notranslate">
				&lt;div id=&quot;right_column&quot; class=&quot;column grid_2 omega&quot;&gt;
					{$HOOK_RIGHT_COLUMN}
				&lt;/div&gt;
</pre>
<p>To</p>
<pre class="brush: php; html-script: true; title: ; notranslate">
				{if $page_name != 'index'}
					&lt;div id=&quot;right_column&quot; class=&quot;column grid_2 omega&quot;&gt;
						{$HOOK_RIGHT_COLUMN}
					&lt;/div&gt;
				{/if}
				
</pre>
<p>There it is, homepage completed!</p>
<p>Moving onto the CMS pages layout, we can simply amend our previous changes and take the page_name &#8216;cms&#8217; into account. So, to hide the right column:</p>
<pre class="brush: php; html-script: true; title: ; notranslate">
				{if $page_name != 'index' AND $page_name != 'cms'}
					&lt;div id=&quot;right_column&quot; class=&quot;column grid_2 omega&quot;&gt;
						{$HOOK_RIGHT_COLUMN}
					&lt;/div&gt;
				{/if}
				
</pre>
<p>Then, to extend our center column, back to header.tpl:</p>
<pre class="brush: php; html-script: true; title: ; notranslate">

&lt;div id=&quot;center_column&quot; class=&quot;{if $page_name == 'index'}grid_9{elseif $page_name == 'cms'}grid_7 omega{else}grid_5{/if}&quot;&gt;
				
</pre>
<p><strong>Explanation: alpha and omega.</strong> If you are wondering why I added &#8216;omega&#8217; to this last block, instead of simply leaving grid_7 (which is, 7 columns over a total of 9, considering we still have the left column there), it&#8217;s because of margins. <strong>All blocks but grid_9 have a margin; adding alpha will kill the left margin, adding omega will kill the right one.</strong> This way, all blocks will fit into their space like puzzle pieces.</p>
<div class="separator"></div>
<h2>Varying the column layout in Prestashop &#8211; the CSS way</h2>
<p>Using the previous method is certainly effective, and it&#8217;s okay on most pages. However, in some pages, like the checkout using one-page-checkout, it will simply fail. No matter what you&#8217;ll do, your center column will never cover the whole space. This is because on certain pages prestashop assigns a fixed width to the template. Here is an example taken from global.css</p>
<pre class="brush: css; title: ; notranslate">
#order-opc #center_column {
	width: 757px;
}
</pre>
<p>As you can see, it has a fixed width. In addition, notice how we can actually target the specific page and change the width (and more) using css, since that ID is nothing but the $page_name. Let&#8217;s open up <strong>global.css</strong> located at <em>themes/themename/css/</em>. Look for the line I mentioned above. Now change it to</p>
<pre class="brush: css; title: ; notranslate">
#order-opc #center_column {
	width: 980px;
}
</pre>
<p>Refresh, and you&#8217;ll see the center column taking up all the space all of a sudden. It&#8217;s then time to hide the right column. Note that this will simply hide it, and the actual html will still be parsed. Add this right after the previous modifications</p>
<pre class="brush: css; title: ; notranslate">
#order-opc #right_column {
	display:none
}
</pre>
<p>There, the right column&#8217;s gone!</p>
<div class="separator"></div>
<h2>The mixed way</h2>
<p>The first method we saw is cool since it will not render part of the template (though hooks will still be processed because they are assigned in a controller, perhaps a subject for some new tutorial? Let me know). However, as we saw it is useless in some pages. On the other hand, while it&#8217;s really easy to edit css, those blocks we hide are&#8230;uh, only hidden! What about going for a mixed way? You can try it yourself on the product page. Add the code to remove the left or right column (or both). Then, open up <strong>product.css</strong> and look for <strong>#pb-left-column</strong> and <strong>#pb-right-column</strong>. Change their size to account for the new space, but <strong>bear in mind their names are actually inverted!</strong>.</p>
<p>The post <a rel="nofollow" href="http://nemops.com/columns-for-each-prestashop-page/">Specifying the number of columns for each Prestashop page</a> appeared first on <a rel="nofollow" href="http://nemops.com">NemoPS</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://nemops.com/columns-for-each-prestashop-page/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>
