[Snippet] Allow PHP in Smarty (CubeCart 5)

Although it is generally bad practise to put PHP code directly into your (CubeCart 5) Smarty templates, its sometimes inenvitable.

You will need to edit controllers/controller.index.inc.php

Change

$GLOBALS['smarty']->allow_php_tag = false;

To

$GLOBALS['smarty']->allow_php_tag = true;

This will enable PHP in your templates

[codesyntax lang=”smarty”]
{php}
echo ‘Guten Morgen’;
{/php}

 

Author: Kieran Barnes

Kieran is a PHP developer with 15 years commercial experience. Specialist in WordPress, CakePHP, CubeCart and all things PHP.

One thought on “[Snippet] Allow PHP in Smarty (CubeCart 5)”

  1. How about adding PHP code to a site doc in CCv5? I didn’t have the line you mentioned above in the smarty section of my controller file. I added it, but all of the PHP code keeps getting commented out when the site doc is saved. Thanks.

Leave a Reply

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