Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Smarty is a PHP template engine for PHP, which facilitates the separation of presentation (XHTML/CSS) from the PrestaShop's core functions/controllers.</p> <p>A template file (usually with a .tpl extension in PrestaShop) is always called by a PHP controller file (it can be a Front-end core controller or a module controller).</p> <p>Example: <code>/prestashop/controllers/front/ContactController.php</code></p> <pre><code>$this-&gt;context-&gt;smarty-&gt;assign(array( 'contacts' =&gt; Contact::getContacts($this-&gt;context-&gt;language-&gt;id), 'message' =&gt; html_entity_decode(Tools::getValue('message')) )); $this-&gt;setTemplate(_PS_THEME_DIR_.'contact-form.tpl'); </code></pre> <p>We can see that this file is retrieving information from the database and assigning it to Smarty.</p> <p>Then, the 'contact-form.tpl' template will display it to the visitors.</p> <p>The syntax is pretty similar for modules, example:<code>/prestashop/modules/blocklink/blocklink.php</code></p> <pre><code>public function hookLeftColumn($params) { $this-&gt;smarty-&gt;assign('blocklink_links', $this-&gt;getLinks()); return $this-&gt;display(__FILE__, 'blocklink.tpl'); } </code></pre> <p>Also, to store values in Smarty variables, you can use the 'assign' function in two ways:</p> <ol> <li><p><code>$this-&gt;context-&gt;smarty-&gt;assign('my_smarty_variable_name', $my_value);</code></p> <p>or if you have several variables:</p></li> <li><p><code>$this-&gt;context-&gt;smarty-&gt;assign(array('my_smarty_variable_name1' =&gt; $my_value1), ('my_smarty_variable_name2' =&gt; $my_value2));</code></p></li> </ol> <p>And then in the Smarty template:</p> <pre><code>The value of my variable is {$my_smarty_variable_name|escape:'htmlall':'UTF-8'}. </code></pre> <p>The 'escape' modifier is used to avoid XSS security issues.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload