Answer the question
In order to leave comments, you need to log in
How to make php work in .tpl?
Hello. Help me to understand. There is a code in PHP, I need to insert it in a certain place on the site, but when I insert it it doesn’t work, because the file extension where I insert .tpl is visible. How can I make the code work there?
I tried: 1. I
found a php file in which tpl is connected, I wanted to organize it with a function, but I still didn’t understand what to write there.
2. In a file with the .tpl extension, inserting php code between {php} does not work either.
Answer the question
In order to leave comments, you need to log in
Naturally, it does not work there, because .tpl files should not contain PHP code - these are templates that receive the result of the PHP code in the form of variables. Find where the template you need is called and pass it the required string as a variable.
If you have PHP running as an Apache web server module, try writing this in .htaccess in the folder where the desired file with the .tpl extension is located
AddType application/x-httpd-php .tpl
AddHandler x-httpd-php .tpl
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question