I am new to smarty and I want to use php code in template file i-e tpl file. I have seen the documentation and searched on google but could not find how to use php code they say we need to configure smarty to allow php execution but could not find how to do it.
Kindly help me in this regard. Thanks
TPL is a template file which is a common text file that contains user-defined variables that are entitled to be overridden by user-defined output content when a PHP web application parses the template file. These are used by web applications with server script PHP(but not restricted to) as a template file.
Smarty is a web template system written in PHP. Smarty is primarily promoted as a tool for separation of concerns. Smarty is intended to simplify compartmentalization, allowing the front-end of a web page to change separately from its back-end.
How does it work? Under the hood, Smarty compiles copies of the templates as PHP scripts. This way you get the benefits of both template tag syntax and the speed of PHP. Compilation happens once when each template is first invoked, and then the compiled versions are used from that point forward.
Easy as boiling an egg!
{php}echo "hello!"{/php}
Second link down, for reference.
Edit as of Smarty 3.1:
As of Smarty 3.1 the {php} tags are only available from SmartyBC.
Source: http://www.smarty.net/docs/en/language.function.php.tpl
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With