Back to Top

Available global variables in PrestaShop templates

Updated 17 January 2024

In this blog, we are going to learn how to use available global variables in PrestaShop templates for front controller templates.

PrestaShop offers predefined variables for the front office smarty templates, which are set in classes/FrontController.php

Firstly, while developing module whenever we create any front controller and write parent::initContent(); all available variables in PrestaShop smarty templates are assigned to that front controller template automatically.

Available global variables is PrestaShop templates
Predefined global variables

List of variables

  • Cart: Utilised in the template, the cart variable provides access to contextual cart information.
  • Currency: The currency variable facilitates obtaining information regarding the shop’s currency.
  • Customer: The customer variable in the template facilitates access to information about the logged-in customer.
  • Language: The language variable indicates the current language used in the shop.
  • Page: The page variable in the template enables obtaining details about the currently opened page..
  • Shop: The shop variable in the template provides contextual information about the shop.
  • Urls: The Urls variable, serving as a Smarty variable, encompasses all publicly available URLs in PrestaShop.
  • Configuration: The configuration variable in the template holds details about the shop’s configuration.
  • Field_required: The field_required feature highlights errors indicating required fields on a page.
  • Breadcrumb: The breadcrumb variable contains descriptions and URLs of the paths that users have navigated from the home page.
  • Link: The Link variable encompasses information about the Link Class, including the URL protocol used.
  • Time: The time variable in the template denotes the current Unix timestamp.
  • Token: The Token feature furnishes the CSRF token, serving as a preventive measure against Cross-Site Request Forgery.
  • Debug: The debug variable indicates whether the shop is in debug mode or not.

In the development of your module, you can effectively utilize these variables, given that they are globally available. This is particularly true if your controller has an init content, as follows. Additionally, developers frequently rely on some of these variables, eliminating the need to assign them explicitly.

public function initContent()
{
    parent::initContent(); 
}

Moreover, if you are seeking to extend these global variables and incorporate additional ones of your own, you can refer to this link Add global variables to javascript objects and smarty templates using PrestaShop.

Searching for an experienced
Prestashop Company ?
Find out More

That’s all about this blog. Hope it will help you.

Concluding this blog, I hope it proves helpful to you. If you encounter any issues or have doubts about the aforementioned process, please don’t hesitate to contact us through the comment section.

Also, you can explore our PrestaShop Development Services and a large range of quality PrestaShop Modules.

For any doubt contact us at [email protected]

. . .

Leave a Comment

Your email address will not be published. Required fields are marked*


Be the first to comment.

Back to Top

Message Sent!

If you have more details or questions, you can reply to the received confirmation email.

Back to Home