0
votes

I was trying to change the layout of the side menu. So I went to theme editor of opencart admin backend and edit the header.twig file. Then my site immediately went down. I tried reset the file but no help. Below are some details.

Opencart version: 3.0.2.0 Template used: default template(It is Laparis) File edited: header.twig(Already reset but no help)

Error message from log:

Fatal error: Uncaught exception 'Twig_Error_Syntax' with message 'Unknown "str_replace" function in "__string_template__114ffe1f7b42f3814d23134616d33d0e68757819b2b243a229946d6b949a3d2d" at line 18.' in /home/lbabatkcom/public_html/demo/system/library/template/Twig/ExpressionParser.php:574 Stack trace: #0 /home/lbabatkcom/public_html/demo/system/library/template/Twig/ExpressionParser.php(351): Twig_ExpressionParser->getFunctionNodeClass('str_replace', 18) #1 /home/lbabatkcom/public_html/demo/system/library/template/Twig/ExpressionParser.php(144): Twig_ExpressionParser->getFunctionNode('str_replace', 18) #2 /home/lbabatkcom/public_html/demo/system/library/template/Twig/ExpressionParser.php(84): Twig_ExpressionParser->parsePrimaryExpression() #3 /home/lbabatkcom/public_html/demo/system/library/template/Twig/ExpressionParser.php(41): Twig_ExpressionParser->getPrimary() #4 /home/lbabatkcom/public_html/demo/system/library/template/Twig/ExpressionParser.php(91): Twig_ExpressionParser->parseExpression() #5 /home/lbabatkcom/public in /home/lbabatkcom/public_html/demo/system/library/template/Twig/ExpressionParser.php on line 574

I thought it might be the cache issue, so I cleared all cache. But still no luck.

1
Please set twig debug is true in /system/library/template/Twig/Environment.php set $options = array_merge(array( 'debug' => true, (flase to true) 'charset' => 'UTF-8', 'base_template_class' => 'Twig_Template', 'strict_variables' => false, 'autoescape' => 'html', 'cache' => false, 'auto_reload' => null, 'optimizations' => -1, ), $options);vijay rami
i did that, nothing happenedmohammad mahmoud

1 Answers

1
votes

You can't execute PHP in a Twig file.

You can run PHP code in the controller then pass the result to the Twig file.