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');
{php}
has been deprecated. Have a look at Extending Smarty With Plugins.
put the follwing in …/plugins/function.yourplugin.php
:
<?php
function smarty_function_yourplugin(array $params, Smarty_Template_Instance) {
include 'your_other_file.php';
}
and use in your template:
{yourplugin}
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.
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