Friday, August 28, 2015

Add back button to prestashop1.6 inside product page

This code shows how to add back button inside prestashops product page, The button will only show if you are inside a product page ,you can also add the codes to breadcrumbs.tpl for better viewing
{if $page_name == 'product'} 
 <div class="pull-right">   
   <a class="backCat" href="{$link->getCategoryLink($category->id_category, $category->link_rewrite)|escape:'html':'UTF-8'}" title="Back"><i class="fa fa-arrow-left"></i> Back</a>
 </div> 
{/if}
Css
.backCat{
 display: inline-block;
 padding: 0px 11px;
 border: 1px solid #D6D4D4;
 font-weight: bold;
 font-size: 12px;
 line-height: 24px;
 min-height: 6px;
 border-radius: 3px;
 overflow: hidden;
 margin-bottom: 16px;
 position: relative;
 z-index: 1;
}
In some case, if the category of our product is two or more, we can use an alternative that is much simple
<a class="backCat" href="{literal}javascript:history.back();{/literal}" title="Back"><i class="fa fa-arrow-left"></i> Back</a>