Prestashop 1.6 vs 1.7 Comparison

February 7, 2018 Ivan Orlovsky Prestashop
Prestashop 1.6 vs 1.7 Comparison

When it comes to Prestashop 1.7, it should be mentioned that the developers have implemented the additional features to deal with Smarty.

{url}

{url} function is meant for working with URL addresses. It works via the standard class PrestaShop «Link». For example,

The result,
dev2.belvg.net/prestashop_one_seven/ru/address
dev2.belvg.net/prestashop_one_seven/ru/address
dev2.belvg.net/prestashop_one_seven/ru/address?delete=1

In Prestashop 1.6 there’s no such function for Smarty, that’s why you have to collect URL into an array and do it for your needs. For example,

– template code.

–  php file code.

*Be careful while dealing with “Link”. If you have to make a friendly URL, there can be some problems, if something is done incorrectly.

{widget}

{widget} allows considering the module connection in a different way. Instead of using standard hook, you can use {widget}. For example,

If your standard module template is replaced, you can put the link to the necessary hook into {widget}. For example,

Pay attention to the fact that all {widget} work only with modules for Prestashop 1.7 the names of which start from «ps_».

In Prestashop 1.6 you need to go to the folder that contains the module \modules\blockcontactinfos and add your custom hook in the file blockcontactinfos.phpFor example,

Then you can call it anywhere. For example,

Actually, in Prestashop 1.6 there’s one more method. You can go to the module directly. But this method is better to use if you are master of complex structures (e. x. hook in hook and one more hook is implied). For example,

The result is that the store data is displayed in the created block.

Prestashop 1.6 vs. 1.7. Comparison_1

{widget_block}

Using {widget_block}, you can rewrite the template.  The module will use your written code as well as the template file code.

As an example, let’s consider the module ps_imageslider \modules\ps_imageslider\views\templates\hook\list.tpl.

In Prestashop 1.6 in your theme template (pic 1) of the modules folder you need to create a folder (pic 2) with the name of module structure you want to change (pic 3) and there create *.tpl (pic 4) and make its own structure.

Prestashop 1.6 vs. 1.7. Comparison_2

Picture 1

Prestashop 1.6 vs. 1.7. Comparison_3

Picture 2

Prestashop 1.6 vs. 1.7. Comparison_4

Picture 3

Prestashop 1.6 vs. 1.7. Comparison_5

Picture 4

{render}

The function allows selecting a variable from the template. For example,

In the template  login-form.tpl, the variable «UI» is described and can be used with the help of {render}.  {render} is the PrestaShop function which has been added in Smarty.

In Prestashop 1.6 “include” is used. So you can put the part of the code, function or variable somewhere according to the user’s needs. But you need to specify the pathname of the code file being used.

NOTE! It can lead to negative consequences. Your website may be hacked, as the hacker is provided with significant files data.

For example,
— mymodule.php
— views
—- templates
—— hook
—— displayFooBarTemplate.tpl
——– inc
———- foo.tpl
———- bar.tpl

The absolute pathname:

Then in your file tpl (displayFooBarTemplate.tpl):

The relative pathname:

{form_field}

The function allows form elements to have the common design. Before there was misunderstanding between frontend and backend developers when they had to use form fields differently. Now the developer can apply almost the same parameters for form fields. For example,

$field – array where parameters are specified.

In Prestashop 1.6 you have to do it manually. For example,

NOTE: if it’s necessary to add a custom attribute to the form, it can’t be performed via {form_field} and you’ll have to do it manually also.

Classname

It’s a modifier that helps to avoid making mistakes when creating class or line. It allows the following:

1. to make your class or line lowercase.
2. to replace all characters different to ASCII.
3. to replace all characters (!@#$%^&*()) to dash (–).
4. to replace all spaces as well as low lines (_) and make class (line) the same.

For example,

Prestashop 1.6 vs. 1.7. Comparison_6

Prestashop 1.6 vs. 1.7. Comparison_7

Prestashop 1.6 vs. 1.7. Comparison_8

Prestashop 1.6 vs. 1.7. Comparison_9

If you want to use BEM methodology in your project, so there’s no need to use this modifier. In Prestashop 1.6 you have to put class names as well as correctness checking.

Classnames

The modifier takes array where the key is class name and parameters take on boolean value (true/false) in order to define the necessity to get it displayed. For example,

\controllers\front\listing\CategoryController.php

Go the template where we need to display the necessary class:

\themes\classic\templates\catalog\listing\product-list.tpl

The result,

Prestashop 1.6 vs. 1.7. Comparison_10

NOTE: Every classname is passed via classname modifier.

In  Prestashop 1.6 there is no such function.



1 comment

Post a new comment

top
BelVG Newsletter
Subscribe to our mailing list and get interesting stuff and updates to your email inbox.
Email *