<?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; prestashpo 1.6</title>
	<atom:link href="https://nemops.com/tag/prestashpo-1-6/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>Flash Tip: Fixing broken buttons in Prestashop 1.6&#8217;s back office</title>
		<link>https://nemops.com/prestashop-broken-buttons/</link>
		<comments>https://nemops.com/prestashop-broken-buttons/#comments</comments>
		<pubDate>Fri, 25 Apr 2014 09:12:59 +0000</pubDate>
		<dc:creator><![CDATA[Nemo]]></dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[buttons]]></category>
		<category><![CDATA[cms block]]></category>
		<category><![CDATA[prestashpo 1.6]]></category>

		<guid isPermaLink="false">http://nemops.com/?p=1965</guid>
		<description><![CDATA[<p>Many Prestashop 1.6 modules have broken buttons in the back office. Let&#8217;s see how to fix them, and apply one of the procedures to the CMS Block Module! The CMS block &#8216;New Block&#8217; example We will use the broken CMS Block back office as guinea pig for this quick tip. If you access its back [&#8230;]</p>
<p>The post <a rel="nofollow" href="https://nemops.com/prestashop-broken-buttons/">Flash Tip: Fixing broken buttons in Prestashop 1.6&#8217;s back office</a> appeared first on <a rel="nofollow" href="https://nemops.com">NemoPS</a>.</p>
]]></description>
				<content:encoded><![CDATA[<p>Many Prestashop 1.6 modules have broken buttons in the back office. Let&#8217;s see how to fix them, and apply one of the procedures to the CMS Block Module!</p>
<p><span id="more-1965"></span></p>
<h2>The CMS block &#8216;New Block&#8217; example</h2>
<p>We will use the broken CMS Block back office as guinea pig for this quick tip. If you access its back office (<em>modules -> CMS Block -> click configure</em>) Nothing is going to happen. Same for the cancel button.</p>
<p>Here are the troublesome lines, taken from <strong>blockcms.php</strong></p>
<pre class="brush: php; title: ; notranslate">
		$this-&gt;fields_form[0]['form'] = array(
			'legend' =&gt; array(
				'title' =&gt; $this-&gt;l('CMS block configuration'),
				'icon' =&gt; 'icon-list-alt'
			),
			'input' =&gt; array(
				array(
					'type' =&gt; 'cms_blocks',
					'label' =&gt; $this-&gt;l('CMS Blocks'),
					'name' =&gt; 'cms_blocks',
					'values' =&gt; array(
						0 =&gt; BlockCMSModel::getCMSBlocksByLocation(BlockCMSModel::LEFT_COLUMN, Shop::getContextShopID()),
						1 =&gt; BlockCMSModel::getCMSBlocksByLocation(BlockCMSModel::RIGHT_COLUMN, Shop::getContextShopID()))
				)
			),
			'buttons' =&gt; array(
				'newBlock' =&gt; array(
					'title' =&gt; $this-&gt;l('New block'),
					'href' =&gt; $current_index.'&amp;amp;configure='.$this-&gt;name.'&amp;amp;token='.$token.'&amp;amp;addBlockCMS',
					'class' =&gt; 'pull-right', 
					'icon' =&gt; 'process-icon-new'
				)
			)
		);
</pre>
<p>As you can see, for some reason this module is using <strong>href</strong> on a button element. Which is simply insane, as a button doesn&#8217;t have an href property! How to overcome this? Let&#8217;s have a look at <strong>*adminfolder*\themes\default\template\helpers\form\form.tpl</strong>, which is the default template used to generate a new form with the helper class:</p>
<pre class="brush: php; html-script: true; title: ; notranslate">
						{if isset($fieldset['form']['buttons'])}
						{foreach from=$fieldset['form']['buttons'] item=btn key=k}
							&lt;button type=&quot;{if isset($btn['type'])}{$btn['type']}{else}button{/if}&quot; {if isset($btn['id'])}id=&quot;{$btn['id']}&quot;{/if} class=&quot;btn btn-default{if isset($btn['class'])} {$btn['class']}{/if}&quot; name=&quot;{if isset($btn['name'])}{$btn['name']}{else}submitOptions{$table}{/if}&quot;{if isset($btn.js) &amp;&amp; $btn.js} onclick=&quot;{$btn.js}&quot;{/if}&gt;{if isset($btn['icon'])}&lt;i class=&quot;{$btn['icon']}&quot; &gt;&lt;/i&gt; {/if}{$btn.title}&lt;/button&gt;
						{/foreach}
						{/if}
</pre>
<p>See? No href, obviously. What to do then? Why not using that <strong>js</strong> attribute? That would do the trick. Back to the php file, change the href to the following, or simply add it afterwards:</p>
<pre class="brush: php; title: ; notranslate">
'js' =&gt; 'javascript: window.location.href = \''.$current_index.'&amp;amp;configure='.$this-&gt;name.'&amp;amp;token='.$token.'&amp;amp;addBlockCMS\'',
</pre>
<p>The array after the change is applied (I replaced the href):</p>
<pre class="brush: php; title: ; notranslate">
		$this-&gt;fields_form[0]['form'] = array(
			'legend' =&gt; array(
				'title' =&gt; $this-&gt;l('CMS block configuration'),
				'icon' =&gt; 'icon-list-alt'
			),
			'input' =&gt; array(
				array(
					'type' =&gt; 'cms_blocks',
					'label' =&gt; $this-&gt;l('CMS Blocks'),
					'name' =&gt; 'cms_blocks',
					'values' =&gt; array(
						0 =&gt; BlockCMSModel::getCMSBlocksByLocation(BlockCMSModel::LEFT_COLUMN, Shop::getContextShopID()),
						1 =&gt; BlockCMSModel::getCMSBlocksByLocation(BlockCMSModel::RIGHT_COLUMN, Shop::getContextShopID()))
				)
			),
			'buttons' =&gt; array(
				'newBlock' =&gt; array(
					'title' =&gt; $this-&gt;l('New block'),
					'js' =&gt; 'javascript: window.location.href = \''.$current_index.'&amp;amp;configure='.$this-&gt;name.'&amp;amp;token='.$token.'&amp;amp;addBlockCMS\'',
					'class' =&gt; 'pull-right', 
					'icon' =&gt; 'process-icon-new'
				)
			)
		);
</pre>
<p>Save and refresh, it works!</p>
<div class="separator"></div>
<h2>Next up: cancel buttons</h2>
<p>The same module has a broken &#8216;cancel&#8217; button when you try to edit a block. Not such a big deal, but let&#8217;s see how to fix it as well! Locate:</p>
<pre class="brush: php; title: ; notranslate">
'cancelBlock' =&gt; array(
					'title' =&gt; $this-&gt;l('Cancel'),
					'href' =&gt; $back,
					'icon' =&gt; 'process-icon-cancel'
				)
</pre>
<p>And change it to:</p>
<pre class="brush: php; title: ; notranslate">
	'cancelBlock' =&gt; array(
					'title' =&gt; $this-&gt;l('Cancel'),
					'js' =&gt; 'javascript: window.location.href = \'' . $back .'\'',
					'icon' =&gt; 'process-icon-cancel'
				)
</pre>
<div class="separator"></div>
<h2>&#8230;and all other broken buttons? An alternative</h2>
<p>Do we have to change every single occurrence of that broken button? Yes, indeed. Is there an alternative way? Of course, but this means no other associated javascript will work. Instead of editing the php file as we did, open <strong>*adminfolder*\themes\default\template\helpers\form\form.tpl</strong> directly. Once more, locate:</p>
<pre class="brush: php; html-script: true; title: ; notranslate">
						{if isset($fieldset['form']['buttons'])}
						{foreach from=$fieldset['form']['buttons'] item=btn key=k}
							&lt;button type=&quot;{if isset($btn['type'])}{$btn['type']}{else}button{/if}&quot; {if isset($btn['id'])}id=&quot;{$btn['id']}&quot;{/if} class=&quot;btn btn-default{if isset($btn['class'])} {$btn['class']}{/if}&quot; name=&quot;{if isset($btn['name'])}{$btn['name']}{else}submitOptions{$table}{/if}&quot;{if isset($btn.js) &amp;&amp; $btn.js} onclick=&quot;{$btn.js}&quot;{/if}&gt;{if isset($btn['icon'])}&lt;i class=&quot;{$btn['icon']}&quot; &gt;&lt;/i&gt; {/if}{$btn.title}&lt;/button&gt;
						{/foreach}
						{/if}
</pre>
<p>And change it to</p>
<pre class="brush: php; html-script: true; title: ; notranslate">
						{if isset($fieldset['form']['buttons'])}
						{foreach from=$fieldset['form']['buttons'] item=btn key=k}
							&lt;button type=&quot;{if isset($btn['type'])}{$btn['type']}{else}button{/if}&quot; {if isset($btn['id'])}id=&quot;{$btn['id']}&quot;{/if} class=&quot;btn btn-default{if isset($btn['class'])} {$btn['class']}{/if}&quot; name=&quot;{if isset($btn['name'])}{$btn['name']}{else}submitOptions{$table}{/if}&quot;{if isset($btn.js) &amp;&amp; $btn.js} onclick=&quot;{$btn.js}&quot;{/if} {if isset($btn.href) &amp;&amp; $btn.href} onclick=&quot;javascript: window.location.href = '{$btn.href}'&quot;{/if}&gt;{if isset($btn['icon'])}&lt;i class=&quot;{$btn['icon']}&quot; &gt;&lt;/i&gt; {/if}{$btn.title}&lt;/button&gt;
						{/foreach}
						{/if}
</pre>
<p>What did we do? We added</p>
<pre class="brush: php; html-script: true; title: ; notranslate">
{if isset($btn.href) &amp;&amp; $btn.href} onclick=&quot;javascript: window.location.href = '{$btn.href}'&quot;{/if}
</pre>
<p>So that any href is automatically turned into an onclick event.</p>
<div class="separator"></div>
<h2>Conclusion</h2>
<p>Both ways have their own disadvantage, the first being having to change every single instance of that button&#8217;s href, the latter the fact that you might as well need other javascript to be triggered. Which one you choose highly depends on your store&#8217;s needs and installed modules!</p>
<p>The post <a rel="nofollow" href="https://nemops.com/prestashop-broken-buttons/">Flash Tip: Fixing broken buttons in Prestashop 1.6&#8217;s back office</a> appeared first on <a rel="nofollow" href="https://nemops.com">NemoPS</a>.</p>
]]></content:encoded>
			<wfw:commentRss>https://nemops.com/prestashop-broken-buttons/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
