Get Free Audit

Template Inheritance in Prestashop 1.7

Mar 7, 2018

3276 Ivan Orlovsky

Template Inheritance in Prestashop 1.7

The article is dedicated to Prestashop 1.7 and its distinctions. You’ll find out how template inheritance is executed in Prestashop 1.7 and the number of differences with Prestashop 1.6.

The principle

If compared with Prestashop 1.6, the Prestashop 1.7 themes must be designed using template inheritance which is considered to be the key difference. Template inheritance is a method of managing templates which is similar to object-oriented programming. Instead of traditional using {include …} tags to manage the part of templates, you can inherit the block content to another one (for example, to complement the class) and change the content (for example, to reassign the class methods). It makes template management more efficient, as the template contains the only differences to complement.

In Prestashop 1.7 developers had to give up on homemade framework being used for a long time, as it poorly performed functions such as items order. Moreover, its maintenance takes much time and it is not considered as specific functions which deserve careful attention. Using popular framework gives an opportunity to upgrade some parts allowing users to enjoy its stable performance. The choice was made and Symfony 2 was selected for Prestashop 1.7. From a technical point of view, this is a major step to Prestashop and is going to last gradually. Now template inheritance is a common concept popular among main templates, so Prestashop starts supporting Twig. As a result, rendering can be executed fast and header.tpl & footer.tpl files are not mandatory.

The new catalog structure

Template Inheritance in Prestashop 1.7_1
In Prestashop theme, many pages look the same, for example, products with templates: categories, new products, search result, and etc. They display the list of products, that’s why in Prestashop 1.7 they are expanding catalog/listing/product-list.tpl.

Andrey_Dubina
Partner With Us Let's discuss how to grow your business. Get a Free Quote.
Talk to Andrey


$layout is a variable which is always available and you can change it.

The template displays the title and the list of products below. Let’s make a nice description containing the picture for category page. So we need to override product_list_header.


It minimizes the code.

The relative template path

Now we can enable the template without using $tpl_dir variable. Templates will be accepted starting from current theme root directory:

Andrey Dubina
Partner With Us Looking for a partner to grow your business? We are the right company to bring your webstore to success. Talk to Andrey

Post a new comment

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