N
N
Nikolay2017-07-08 07:35:06
CMS
Nikolay, 2017-07-08 07:35:06

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

2 answer(s)
E
empr, 2017-07-08
@Semenov-Nikolay

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.

T
Twelfth Doctor, 2017-07-08
@verdex

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

This line will tell the web server to process PHP code in .tpl files

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question