{"id":418137,"date":"2024-01-17T11:03:41","date_gmt":"2024-01-17T11:03:41","guid":{"rendered":"https:\/\/webkul.com\/blog\/?p=418137"},"modified":"2024-01-17T11:11:07","modified_gmt":"2024-01-17T11:11:07","slug":"available-global-variables-in-prestashop-templates","status":"publish","type":"post","link":"https:\/\/webkul.com\/blog\/available-global-variables-in-prestashop-templates\/","title":{"rendered":"Available global variables in PrestaShop  templates"},"content":{"rendered":"\n<p>In this blog, we are going to learn how to\u00a0use\u00a0<strong>available global variables in PrestaShop templates<\/strong>\u00a0for front controller templates.<\/p>\n\n\n\n<p>PrestaShop offers predefined variables for the front office smarty templates, which are set in <code><strong>classes\/FrontController.php<\/strong><\/code><\/p>\n\n\n\n<p>Firstly, while developing module whenever we create any front controller and write <code><strong>parent::initContent()<\/strong>;<\/code> all available variables in PrestaShop smarty templates are assigned to that front controller template automatically.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full is-resized\"><img decoding=\"async\" src=\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2024\/01\/Screenshot-from-2024-01-17-15-10-50.png-1366%C3%97768.png\" alt=\"Available global variables is PrestaShop templates\" class=\"wp-image-418144\" style=\"width:822px;height:auto\" loading=\"lazy\" \/><figcaption class=\"wp-element-caption\">Predefined global variables<\/figcaption><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">List of variables<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Cart<\/strong>: Utilised in the template, the cart variable provides access to contextual cart information.<\/li>\n\n\n\n<li><strong>Currency<\/strong>: The currency variable facilitates obtaining information regarding the shop&#8217;s currency.<\/li>\n\n\n\n<li><strong>Customer<\/strong>: The customer variable in the template facilitates access to information about the logged-in customer.<\/li>\n\n\n\n<li><strong>Language<\/strong>: The language variable indicates the current language used in the shop.<\/li>\n\n\n\n<li><strong>Page<\/strong>: The page variable in the template enables obtaining details about the currently opened page..<\/li>\n\n\n\n<li><strong>Shop<\/strong>: The shop variable in the template provides contextual information about the shop.<\/li>\n\n\n\n<li><strong>Urls<\/strong>: The Urls variable, serving as a Smarty variable, encompasses all publicly available URLs in PrestaShop.<\/li>\n\n\n\n<li><strong>Configuration<\/strong>: The configuration variable in the template holds details about the shop&#8217;s configuration.<\/li>\n\n\n\n<li><strong>Field_required<\/strong>: The field_required feature highlights errors indicating required fields on a page.<\/li>\n\n\n\n<li><strong>Breadcrumb<\/strong>: The breadcrumb variable contains descriptions and URLs of the paths that users have navigated from the home page.<\/li>\n\n\n\n<li><strong>Link<\/strong>: The Link variable encompasses information about the Link Class, including the URL protocol used.<\/li>\n\n\n\n<li><strong>Time<\/strong>: The time variable in the template denotes the current Unix timestamp.<\/li>\n\n\n\n<li><strong>Token<\/strong>: The Token feature furnishes the CSRF token, serving as a preventive measure against Cross-Site Request Forgery.<\/li>\n\n\n\n<li><strong>Debug<\/strong>: The debug variable indicates whether the shop is in debug mode or not.<\/li>\n<\/ul>\n\n\n\n<p>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.<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\">public function initContent()\n{\n    parent::initContent(); \n}<\/pre>\n\n\n\n<p>Moreover, if you are seeking to extend these global variables and incorporate additional ones of your own, you can refer to this link <strong><a href=\"https:\/\/webkul.com\/blog\/add-global-variables-to-javascript-objects-and-smarty-templates-using-prestashop-1-7\/\">Add global variables to javascript objects and smarty templates using PrestaShop<\/a><\/strong>.<\/p>\n\n\n\n<p>That\u2019s all about this blog. Hope it will help you.<\/p>\n\n\n\n<p>Concluding this blog, I hope it proves helpful to you. If you encounter any issues or have doubts about the aforementioned process, please don&#8217;t hesitate to contact us through the comment section.<\/p>\n\n\n\n<p>Also, you can explore our&nbsp;<a href=\"https:\/\/webkul.com\/prestashop-development\/\">PrestaShop Development Services<\/a>&nbsp;and a large range of quality&nbsp;<a href=\"https:\/\/store.webkul.com\/PrestaShop-Extensions.html\">PrestaShop Modules<\/a>.<\/p>\n\n\n\n<p>For any doubt contact us at&nbsp;support@webkul.com<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In this blog, we are going to learn how to\u00a0use\u00a0available global variables in PrestaShop templates\u00a0for 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 <a href=\"https:\/\/webkul.com\/blog\/available-global-variables-in-prestashop-templates\/\">[&#8230;]<\/a><\/p>\n","protected":false},"author":386,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[41,209],"tags":[14968,2065],"class_list":["post-418137","post","type-post","status-publish","format-standard","hentry","category-module","category-prestashop","tag-dev","tag-prestashop"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v24.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Available global variables in PrestaShop templates - Webkul Blog<\/title>\n<meta name=\"description\" content=\"How to\u00a0use\u00a0available global variables in PrestaShop module front controller templates, for ease of module development.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/webkul.com\/blog\/available-global-variables-in-prestashop-templates\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Available global variables in PrestaShop templates - Webkul Blog\" \/>\n<meta property=\"og:description\" content=\"How to\u00a0use\u00a0available global variables in PrestaShop module front controller templates, for ease of module development.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/webkul.com\/blog\/available-global-variables-in-prestashop-templates\/\" \/>\n<meta property=\"og:site_name\" content=\"Webkul Blog\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/webkul\/\" \/>\n<meta property=\"article:published_time\" content=\"2024-01-17T11:03:41+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2024-01-17T11:11:07+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2021\/08\/webkul-og.png\" \/>\n\t<meta property=\"og:image:width\" content=\"1200\" \/>\n\t<meta property=\"og:image:height\" content=\"630\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"Vineet Kr. Gupta\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@webkul\" \/>\n<meta name=\"twitter:site\" content=\"@webkul\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Vineet Kr. Gupta\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"3 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/webkul.com\/blog\/available-global-variables-in-prestashop-templates\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/webkul.com\/blog\/available-global-variables-in-prestashop-templates\/\"},\"author\":{\"name\":\"Vineet Kr. Gupta\",\"@id\":\"https:\/\/webkul.com\/blog\/#\/schema\/person\/bb871a3e8dd81b2b0a1690f195da6208\"},\"headline\":\"Available global variables in PrestaShop templates\",\"datePublished\":\"2024-01-17T11:03:41+00:00\",\"dateModified\":\"2024-01-17T11:11:07+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/webkul.com\/blog\/available-global-variables-in-prestashop-templates\/\"},\"wordCount\":427,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/webkul.com\/blog\/#organization\"},\"keywords\":[\"dev\",\"prestashop\"],\"articleSection\":[\"module\",\"prestashop\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/webkul.com\/blog\/available-global-variables-in-prestashop-templates\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/webkul.com\/blog\/available-global-variables-in-prestashop-templates\/\",\"url\":\"https:\/\/webkul.com\/blog\/available-global-variables-in-prestashop-templates\/\",\"name\":\"Available global variables in PrestaShop templates - Webkul Blog\",\"isPartOf\":{\"@id\":\"https:\/\/webkul.com\/blog\/#website\"},\"datePublished\":\"2024-01-17T11:03:41+00:00\",\"dateModified\":\"2024-01-17T11:11:07+00:00\",\"description\":\"How to\u00a0use\u00a0available global variables in PrestaShop module front controller templates, for ease of module development.\",\"breadcrumb\":{\"@id\":\"https:\/\/webkul.com\/blog\/available-global-variables-in-prestashop-templates\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/webkul.com\/blog\/available-global-variables-in-prestashop-templates\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/webkul.com\/blog\/available-global-variables-in-prestashop-templates\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/webkul.com\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Available global variables in PrestaShop templates\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/webkul.com\/blog\/#website\",\"url\":\"https:\/\/webkul.com\/blog\/\",\"name\":\"Webkul Blog\",\"description\":\"\",\"publisher\":{\"@id\":\"https:\/\/webkul.com\/blog\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/webkul.com\/blog\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/webkul.com\/blog\/#organization\",\"name\":\"WebKul Software Private Limited\",\"url\":\"https:\/\/webkul.com\/blog\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/webkul.com\/blog\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2021\/08\/webkul-logo-accent-sq.png\",\"contentUrl\":\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2021\/08\/webkul-logo-accent-sq.png\",\"width\":380,\"height\":380,\"caption\":\"WebKul Software Private Limited\"},\"image\":{\"@id\":\"https:\/\/webkul.com\/blog\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/webkul\/\",\"https:\/\/x.com\/webkul\",\"https:\/\/www.instagram.com\/webkul\/\",\"https:\/\/www.linkedin.com\/company\/webkul\",\"https:\/\/www.youtube.com\/user\/webkul\/\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/webkul.com\/blog\/#\/schema\/person\/bb871a3e8dd81b2b0a1690f195da6208\",\"name\":\"Vineet Kr. Gupta\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/webkul.com\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/b8dd0faa3589c82d64586b71a9e84be11a8b9a8f3b74bb952442b904af1c68f2?s=96&d=https%3A%2F%2Fcdnblog.webkul.com%2Fblog%2Fwp-content%2Fuploads%2F2019%2F10%2Fmike.png&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/b8dd0faa3589c82d64586b71a9e84be11a8b9a8f3b74bb952442b904af1c68f2?s=96&d=https%3A%2F%2Fcdnblog.webkul.com%2Fblog%2Fwp-content%2Fuploads%2F2019%2F10%2Fmike.png&r=g\",\"caption\":\"Vineet Kr. Gupta\"},\"description\":\"Proficient Software Engineer specializing in PrestaShop, with expertise in Mobile App Development, eCommerce Platform Development, and POS services. Delivers innovative, user-focused solutions that enhance functionality and drive efficient business operations.\",\"url\":\"https:\/\/webkul.com\/blog\/author\/vineetkr-gupta008\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Available global variables in PrestaShop templates - Webkul Blog","description":"How to\u00a0use\u00a0available global variables in PrestaShop module front controller templates, for ease of module development.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/webkul.com\/blog\/available-global-variables-in-prestashop-templates\/","og_locale":"en_US","og_type":"article","og_title":"Available global variables in PrestaShop templates - Webkul Blog","og_description":"How to\u00a0use\u00a0available global variables in PrestaShop module front controller templates, for ease of module development.","og_url":"https:\/\/webkul.com\/blog\/available-global-variables-in-prestashop-templates\/","og_site_name":"Webkul Blog","article_publisher":"https:\/\/www.facebook.com\/webkul\/","article_published_time":"2024-01-17T11:03:41+00:00","article_modified_time":"2024-01-17T11:11:07+00:00","og_image":[{"width":1200,"height":630,"url":"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2021\/08\/webkul-og.png","type":"image\/png"}],"author":"Vineet Kr. Gupta","twitter_card":"summary_large_image","twitter_creator":"@webkul","twitter_site":"@webkul","twitter_misc":{"Written by":"Vineet Kr. Gupta","Est. reading time":"3 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/webkul.com\/blog\/available-global-variables-in-prestashop-templates\/#article","isPartOf":{"@id":"https:\/\/webkul.com\/blog\/available-global-variables-in-prestashop-templates\/"},"author":{"name":"Vineet Kr. Gupta","@id":"https:\/\/webkul.com\/blog\/#\/schema\/person\/bb871a3e8dd81b2b0a1690f195da6208"},"headline":"Available global variables in PrestaShop templates","datePublished":"2024-01-17T11:03:41+00:00","dateModified":"2024-01-17T11:11:07+00:00","mainEntityOfPage":{"@id":"https:\/\/webkul.com\/blog\/available-global-variables-in-prestashop-templates\/"},"wordCount":427,"commentCount":0,"publisher":{"@id":"https:\/\/webkul.com\/blog\/#organization"},"keywords":["dev","prestashop"],"articleSection":["module","prestashop"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/webkul.com\/blog\/available-global-variables-in-prestashop-templates\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/webkul.com\/blog\/available-global-variables-in-prestashop-templates\/","url":"https:\/\/webkul.com\/blog\/available-global-variables-in-prestashop-templates\/","name":"Available global variables in PrestaShop templates - Webkul Blog","isPartOf":{"@id":"https:\/\/webkul.com\/blog\/#website"},"datePublished":"2024-01-17T11:03:41+00:00","dateModified":"2024-01-17T11:11:07+00:00","description":"How to\u00a0use\u00a0available global variables in PrestaShop module front controller templates, for ease of module development.","breadcrumb":{"@id":"https:\/\/webkul.com\/blog\/available-global-variables-in-prestashop-templates\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/webkul.com\/blog\/available-global-variables-in-prestashop-templates\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/webkul.com\/blog\/available-global-variables-in-prestashop-templates\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/webkul.com\/blog\/"},{"@type":"ListItem","position":2,"name":"Available global variables in PrestaShop templates"}]},{"@type":"WebSite","@id":"https:\/\/webkul.com\/blog\/#website","url":"https:\/\/webkul.com\/blog\/","name":"Webkul Blog","description":"","publisher":{"@id":"https:\/\/webkul.com\/blog\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/webkul.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/webkul.com\/blog\/#organization","name":"WebKul Software Private Limited","url":"https:\/\/webkul.com\/blog\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/webkul.com\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2021\/08\/webkul-logo-accent-sq.png","contentUrl":"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2021\/08\/webkul-logo-accent-sq.png","width":380,"height":380,"caption":"WebKul Software Private Limited"},"image":{"@id":"https:\/\/webkul.com\/blog\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/webkul\/","https:\/\/x.com\/webkul","https:\/\/www.instagram.com\/webkul\/","https:\/\/www.linkedin.com\/company\/webkul","https:\/\/www.youtube.com\/user\/webkul\/"]},{"@type":"Person","@id":"https:\/\/webkul.com\/blog\/#\/schema\/person\/bb871a3e8dd81b2b0a1690f195da6208","name":"Vineet Kr. Gupta","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/webkul.com\/blog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/b8dd0faa3589c82d64586b71a9e84be11a8b9a8f3b74bb952442b904af1c68f2?s=96&d=https%3A%2F%2Fcdnblog.webkul.com%2Fblog%2Fwp-content%2Fuploads%2F2019%2F10%2Fmike.png&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/b8dd0faa3589c82d64586b71a9e84be11a8b9a8f3b74bb952442b904af1c68f2?s=96&d=https%3A%2F%2Fcdnblog.webkul.com%2Fblog%2Fwp-content%2Fuploads%2F2019%2F10%2Fmike.png&r=g","caption":"Vineet Kr. Gupta"},"description":"Proficient Software Engineer specializing in PrestaShop, with expertise in Mobile App Development, eCommerce Platform Development, and POS services. Delivers innovative, user-focused solutions that enhance functionality and drive efficient business operations.","url":"https:\/\/webkul.com\/blog\/author\/vineetkr-gupta008\/"}]}},"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/posts\/418137","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/users\/386"}],"replies":[{"embeddable":true,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/comments?post=418137"}],"version-history":[{"count":17,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/posts\/418137\/revisions"}],"predecessor-version":[{"id":418201,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/posts\/418137\/revisions\/418201"}],"wp:attachment":[{"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/media?parent=418137"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/categories?post=418137"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/tags?post=418137"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}