I need to display some external data from php file to .tpl file. For this I want to include php file to .tpl file. I have tried folllowing code to display php file content to tpl.
{php} include('custom_code.php'); {/php}
but on page output was include('custom_code.php');
There is a best practise guide on smarty homepage. #1 is Do not embed PHP!
http://www.smarty.net/best_practices
Try this:
{include_php file="/path/to/somefile.php"}
But notice:
So best way is to write a smarty plugin as explained by rodneyrehm
You shouldn't add PHP code to the template. It will make whole idea of templates spoiled.
You have to add PHP code to controller, not template.
{php}
has been deprecated. Have a look at Extending Smarty With Plugins.put the follwing in
…/plugins/function.yourplugin.php
:and use in your template: