Warning: You are browsing the documentation for PrestaShop 1.7, which is outdated.
You might want to read an updated version of this page for the current version, PrestaShop 8. Read the updated version of this page
This is mostly the easy part. Legacy pages use Smarty while modern pages use Twig. These templating engines are actually similar in many ways.
For instance, this is a legacy template:
<span class="employee_avatar_small">
<img class="img" alt="" src="{$employee_image}" />
</span>
{$employee_name}
admin-dev/themes/default/template/controller
folder… and here is a possible migration of it to Twig:
<span class="employee_avatar_small">
<img class="img" alt="{{ employee.name }}" src="{{ employee.image }}" />
</span>
{{ employee.name }}
The syntax of both engines is really similar. Find out more about Twig by reading the Twig documentation.
All our custom helpers have been ported from Smarty to Twig:
Smarty | Twig |
---|---|
{ l s='foo' d='domain' } |
{{ 'foo'|trans({}, 'domain') }}
|
{ hook h='hookName' } |
{{ renderhook('hookName') }} |
{$link->getAdminLink('AdminAccess')} |
{{ getAdminLink('LegacyControllerName') }} |
Macros/functions are specific to the modern pages to help with recurrent blocks:
Legacy templates use Bootstrap 3 while modern pages use the PrestaShop UI Kit that is based on Bootstrap 4. This means that you’ll need to update some markup (especially CSS classes).
Since we use the jQuery version that is bundled with Bootstrap, old pages use jQuery 1.11 and new ones jQuery 3.3. In addition to this, javascript from old pages was included as separate files without any compilation, while new pages we use modules which are compiled and bundled using Webpack.
Depending on the page you are migrating, this task may be straightforward or more complex.
Example:
<?php
// legacy controller
$this->trans('Before activating the webservice, you must be sure to: ', array(), 'Admin.Advparameters.Help');
… must become:
{{ 'Before activating the webservice, you must be sure to: '|trans({}, 'Admin.Advparameters.Help') }}
PrestaShop uses Webpack to build and bundle static assets in PrestaShop, like Javascript and stylesheets.
/admin-dev/themes/new-theme
.To find out more, read How to compile assets.