Prestashop 1.7.1 | Add a conditional field based on page name in .tpl template

November 30th, 2017

For SEO improvement, i need to adds For SEO improvement, i need to move the field “Short Description”, for manufacturer page, from top to left sidebar.

This modify is made under the “layout-both-columns.tpl”, so, let’s open it.
Immediatly under

 <div id="left-column" class="col-xs-12 col-sm-4 col-md-3">

Add this code:

{$page.page_name}

save, re upload file and reload page, you see that at the bottom of the sidebar ( or immedialty after the sidebar content ), appear the text “manufacturer”, this is the page name.

Once we know this, we can made a conditional, so, replace

{$page.page_name}

with

{if $page.page_name == 'manufacturer'}
  {$manufacturer.short_description nofilter}
{/if}

save, re upload file and reload page, and now you see the short description in right place.

Remember remove short description from “manufacturer.tpl” otherwise you’ll see short description twice

Another example is :

{if $page.page_name == 'product'}
    // what you want to do in product page
{else}
    // what you want to do in other page
{/if}