cotonti.com : PHP code in .tpl https://www.cotonti.com Останні повідомлення в темі Cotonti en Tue, 03 Feb 2026 05:41:15 -0000 Trustmaster There is no way to include PHP files from a template and there will not be for security reasons. If you need a way to include the output of a PHP script in your template, then you should create a plugin that would wrap that PHP script and assign TPL tags, or at least assign its output to some global variable. You can place the PHP code directly into 'themes/your_theme/your_theme.php' file but still it must assign the HTML output to a global variable rather than echoing it.

]]>
Пт, 27 Лип 2012 19:45:37 -0000
duck101 Sorry for my ignorance on callback functions, but how do I tell it where to find my php file. is the code below right?

{PHP.somevariable|my_function('form.php')}

 

]]>
Пт, 27 Лип 2012 18:52:36 -0000
GHengeveld The only way to execute php code directly from a template file is to use a callback function. You can call any php function from your tpl, both built-in and custom functions. The return value will be displayed in the HTML, which means the callback should return a string or a number, or nothing at all. You can use a callback function like this:

{PHP|my_function('param1', 'param2')}

Alternatively, you can combine it with a template tag or php variable:

{MYTAG|my_function()}

{PHP.somevariable|my_function()}

More info: http://www.cotonti.com/docs/ext/themes/cotemplate_advanced

]]>
Пт, 27 Лип 2012 17:14:20 -0000
duck101 Hello, I tried to insert a php code into a tpl file, and for some reason not all of the code would display right. I've heard that php in tpl files is a big no,no. I then tried another option-- <script src=https://www.cotonti.com/"form.php"></script> to no avail.  Is there another way to call up a php file from a tpl file?

]]>
Пт, 27 Лип 2012 16:55:47 -0000