Child pages
  • Creating a PrestaShop module

Versions Compared

Key

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

...

  • 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 it this method once here for clarity readability reasons, but in practice this it should be applied to used on all of the template's strings.

  • the {if}, {else} and {/if} statements are Smarty comparatorsconditionals. In our example, we check that the $name $my_module_name Smarty variable exists (using Smarty's isset() function) 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 {$base$my_dirmodule_link} variable in the link's href attribute: this is a Smarty variable created by PrestaShop, which provides developer with access that we will create later on, which will point to PrestaShop's root directory.

In addition to that, we are going to create a CSS file, and put save it at as /css/mymodule.css in the module's folder (or any sub-folder you like to keep you CSS in):

...

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).

...

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

...