John-nl Posted August 25, 2018 Share Posted August 25, 2018 I wan't to allow php scripts within a smarty template with {php} //my php code {/php} tags. When i use these tags get this smarty error: {php}{/php} tags not allowed. Use SmartyBC to enable them I can see the SmartyBC class in the /vendor/smarty folder and have looked into the three smarty config files within the /config folder, But i cannot figure out how to enable SmartBC in Prestashop 1.7. Thanks Link to comment Share on other sites More sharing options...
Guest Posted August 25, 2018 Share Posted August 25, 2018 You should not use PHP in Smarty. Prestashop pages are split between a controller, several models and several views. PHP stuff belongs in the controller and Smarty/twig stuff in the view. Hacking a way around it is going to cause more frustration in the end. Continue in the controller if you can and use an override if you are lucky enough to be using the last working version of Prestashop. Link to comment Share on other sites More sharing options...
musicmaster Posted August 25, 2018 Share Posted August 25, 2018 PHP was allowed in very old Smarty versions. It is not allowed in the version that Prestashop uses. Smarty code language is quite flexible and you can do quite a bit of processing with it. But things like database access you need to arrange in the code that calls the template. Link to comment Share on other sites More sharing options...
John-nl Posted August 26, 2018 Author Share Posted August 26, 2018 Php is allowed in in smarty 3.1.32 with SmartyBC, the version that Prestashop 1.7 uses. I know that i should use MVC. I would appreciate an answer to my original question. Thanks Link to comment Share on other sites More sharing options...
Guest Posted August 26, 2018 Share Posted August 26, 2018 I am glad that I could have been of any help! Link to comment Share on other sites More sharing options...
John-nl Posted August 26, 2018 Author Share Posted August 26, 2018 I am glad that you think you have helped! I would appreciate an answer to my original question. Link to comment Share on other sites More sharing options...
Knowband Plugins Posted August 27, 2018 Share Posted August 27, 2018 If you are aware about the MVC then not sure why you want to execute the PHP in smarty. Anyway, Edit the config/smarty.config.inc.php & replace the following line. $smarty = new Smarty(); to $smarty = new SmartyBC(); I hope it will help. Link to comment Share on other sites More sharing options...
John-nl Posted August 31, 2018 Author Share Posted August 31, 2018 Thanks for you're answer I have changed new Smarty() to newSmartyBC() on line 34 in config/smarty.config.inc.php But still receive the message {php}{/php} tags not allowed. Use SmartyBC to enable them Any suggestions? 1 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now