Forums / Cotonti / Support / PHP code in .tpl

how to insert php code into tpl files

GHengeveld
#35025 2012-07-27 17:14

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