Versions Compared


  • This line was added.
  • This line was removed.
  • Formatting was changed.


As said earlier, the content to be displayed in the theme should be stored in .tpl template files. We will create the mymodule.tpl file, which was passed as a parameter of the display() method in our module's code, in the hookDisplayLeftColumnhookDisplayHome() method. When calling a template from within a hook, PrestaShop looks for that template file in the /views/templates/hook/ folder (in the module's folder), which you must create yourself.


Code Block
<!-- Block mymodule -->
<div id="mymodule_block_lefthome" class="block">
  <div class="block_content">
       {if isset($my_module_name) && $my_module_name}
      <li><a href="{$my_module_link}" title="Click this link">Click me!</a></li>
<!-- /Block mymodule -->


  • The {l s='xxx' mod='yyy'} call is PrestaShop-specific method that enables you to register the string in the module's translation panel. The s parameter is the string, while the mod parameter must contain the module's identifier (in the present case, "mymodule"). We only use this method once here for readability reasons, but in practice it should be used on all of the template's strings.

  • The {if}, {else} and {/if} statements are Smarty conditionals. In our example, we check that the $my_module_name Smarty variable exists (using SmartyPHP's isset() function, which considered as trusted by Smarty) and that it is not empty. If it goes well, we display the content of that variable; if not, we display "World", in order to have "Hello World".
  • The {$my_module_link} variable in the link's href attribute: this is a Smarty variable that we will create later on, which will point to PrestaShop's root directory.


Code Block
div#mymodule_block_lefthome p { 
  font-size: 150%;

Save the template file in the module's /views/templates/hook/ folder and the CSS file in the module's /css/ folder, reload your shop's homepage: the content of the template should appear on top of the left column, right below the shop's logo (if you have indeed moved it at the top of the "Left Column" hook during the transplanting part).

Image Removed

As you can see, the theme applies its own CSS to the template we added:

  • Our <h4> title becomes the block's header, style styled the same way as the other block titles.
  • Our <div class="block_content"> block has the same style as the other blocks on the page.