<?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; homepage</title>
	<atom:link href="http://nemops.com/tag/homepage/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 new homepage tabs in Prestashop 1.6</title>
		<link>http://nemops.com/prestashop-new-homepage-tabs/</link>
		<comments>http://nemops.com/prestashop-new-homepage-tabs/#comments</comments>
		<pubDate>Tue, 23 Sep 2014 12:32:51 +0000</pubDate>
		<dc:creator><![CDATA[Nemo]]></dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[homepage]]></category>
		<category><![CDATA[module]]></category>
		<category><![CDATA[prestashop]]></category>
		<category><![CDATA[tabs]]></category>

		<guid isPermaLink="false">http://nemops.com/?p=2153</guid>
		<description><![CDATA[<p>In this quick tip we will see how easy it is to create new tabs for the homepage in Prestashop 1.6, by simply enabling two hooks in a module. The basics First, we need a skeleton. That is, a basic module to work with. You can choose an existing one, or follow along in creating [&#8230;]</p>
<p>The post <a rel="nofollow" href="http://nemops.com/prestashop-new-homepage-tabs/">How to create new homepage tabs in Prestashop 1.6</a> appeared first on <a rel="nofollow" href="http://nemops.com">NemoPS</a>.</p>
]]></description>
				<content:encoded><![CDATA[<p>In this quick tip we will see how easy it is to create new tabs for the homepage in Prestashop 1.6, by simply enabling two hooks in a module.</p>
<p><span id="more-2153"></span></p>
<h2>The basics</h2>
<p>First, we need a skeleton. That is, a basic module to work with. You can choose an existing one, or follow along in creating a simple new module for this sole purpose. In the first case, you can jump directly to the next section.</p>
<p>We will not extensively see how to create a Prestashop Module from scratch; therefore, if you need more information about the topic you can have a look at the official Prestashop documentation on <strong><a href="http://doc.prestashop.com/display/PS15/Creating+a+PrestaShop+module" title="creating a Prestashop Module">creating a Prestashop Module</a></strong>.</p>
<p>That said, let&#8217;s create the module&#8217;s folder. Inside <em>modules/</em>, create one named <strong>pshometabs</strong> (or whatever name you prefer, as long as you remind it later on). Then, inside it, create a file named <strong>phometabs.php</strong>. We will not add any icon to the module, as it&#8217;s only meant to demonstrate the procedure. Open up the file and paste the following after an opening php tag:</p>
<pre class="brush: php; title: ; notranslate">


if (!defined('_PS_VERSION_'))
	exit;

class psHomeTabs extends Module
{
	
	public function __construct()
	{
		$this-&gt;name = 'pshometabs';
		$this-&gt;tab = 'front_office_features';
		$this-&gt;version = '1.0';
		$this-&gt;author = 'Nemo';
		$this-&gt;need_instance = 0;

	 	parent::__construct();

		$this-&gt;displayName = $this-&gt;l('PS new homepage tabs');
		$this-&gt;description = $this-&gt;l('Adds a new block to the homepage tabs.');
		$this-&gt;confirmUninstall = $this-&gt;l('Are you sure you want to delete this module?');
	}
	
	public function install()
	{
		if (!parent::install())
			return false;
		return true;
	}
	
}

</pre>
<p>And these are only the barebones of a Prestashop Module. It&#8217;s not doing anything of course, so let&#8217;s register some hooks for the home tabs.</p>
<div class="separator"></div>
<h2>Registering hooks for the home tabs</h2>
<p>First off, we need to support both of the hooks needed for home tabs. They are two, because one displays the label (e.g. Top sellers) and the other the content. Therefore, add the following content to the module&#8217;s class:</p>
<pre class="brush: php; title: ; notranslate">
	public function hookDisplayHomeTab($params)
	{
		return $this-&gt;display(__FILE__, 'tab.tpl');
	}

	public function hookDisplayHomeTabContent($params)
	{
		return $this-&gt;display(__FILE__, 'tab_content.tpl');
	}

</pre>
<p>We could as well be done with php and focus on templating now, but to make our life easier (instead of having to manually register hooks from Modules -> Positions in the back office), let&#8217;s do it in the install() method:</p>
<pre class="brush: php; title: ; notranslate">
	public function install()
	{
		if (!parent::install() OR
			!$this-&gt;registerHook('displayHomeTab') OR
			!$this-&gt;registerHook('displayHomeTabContent'))
			return false;
		return true;
	}
</pre>
<p>Save, login to the back office and test if the module is correctly installing. If it is, move on to creating template files.</p>
<div class="separator"></div>
<h2>Creating the hooks template files</h2>
<p>At this point, we need to display something. But what? Indeed, we need to know what displays where, and if you didn&#8217;t guess it already by the name, <strong>hookDisplayHomeTab</strong> is for the label, while <strong>hookDisplayHomeTabContent</strong> is, needless to say, for the content. Therefore, we need to write the proper label code within the tab.tpl file, and content inside tab_content.tpl. Of course, these files can have other names as well, as long as everything is consistent.</p>
<p>Create the following folder structure inside the module&#8217;s folder: <em>views/templates/hook/</em>. Inside this last one, start by adding the file named <strong>tab.tpl</strong>, and open it, pasting the following inside</p>
<pre class="brush: php; html-script: true; title: ; notranslate">
&lt;li&gt;&lt;a data-toggle=&quot;tab&quot; href=&quot;#pshometabs&quot; class=&quot;pshometabs&quot;&gt;{l s='New Tab' mod='pshometabs'}&lt;/a&gt;&lt;/li&gt;
</pre>
<p>Please notice the content <strong>needs</strong> to have this exact structure if you use the default Prestashop 1.6 template. So you need it to contain a list item, and an anchor tag with the data-toggle attribute, as well as href pointing to the id of the content (which we don&#8217;t have yet). Again, names are extremely important at this stage, make sure there are no duplicates or things won&#8217;t work properly.</p>
<p>Lastly, create <strong>tab_content</strong> and paste the following:</p>
<pre class="brush: php; html-script: true; title: ; notranslate">
&lt;ul id=&quot;pshometabs&quot; class=&quot;pshometabs tab-pane&quot;&gt;
	&lt;li&gt;
		{l s='This is a test message.' mod='pshometabs'}
	&lt;/li&gt;
&lt;/ul&gt;
</pre>
<p>Once more, to be consistent with the default theme, use an ul element with the related id used in the tab part. Make sure it has tab-pane as class, at least. And of course, an li as child, which can contain virtually anything you want.</p>
<p>Save and refresh, if you did everything correctly, after installing it the new tab will appear in the homepage:</p>
<p><a href="http://nemops.com/wp-content/uploads/2014/09/new_home_tabs.png"><img src="http://nemops.com/wp-content/uploads/2014/09/new_home_tabs-680x262.png" alt="How to create new homepage tabs in Prestashop 1.6 - Final Result" width="680" height="262" class="aligncenter size-large wp-image-2155" /></a></p>
<div class="separator"></div>
<h2>Side notes on the template files</h2>
<p>The previous code is meant to work with the default Prestashop 1.6 template. If you use a custom one, I strongly advise you to check how modules hooked to the homepage tabs are buil in the theme folder, modules (e.g. homefeatured). Then, mimic the same structure for the tab and tab content templates.</p>
<p>The post <a rel="nofollow" href="http://nemops.com/prestashop-new-homepage-tabs/">How to create new homepage tabs in Prestashop 1.6</a> appeared first on <a rel="nofollow" href="http://nemops.com">NemoPS</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://nemops.com/prestashop-new-homepage-tabs/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
	</channel>
</rss>
