Danish Khan Danish Khan - 1 year ago 116
Smarty Question

Smarty template file (.tpl) is not loading PHP code

I have a smarty template file and I want to include code from a php file. It simply doesn't work. Here's the sfunc.php in templates folder:

function BeautySweet (){
echo 'Script works fine.';

Now here's the .tpl file code I added:

{include_php 'templates/sfunc.php';}
{ BeautySweet ();}

I also tried:

{include_php 'sfunc.php';}
{ BeautySweet ();}

Still no luck.

Answer Source


{include_php file="templates/sfunc.php"}

instead of

{include_php 'templates/sfunc.php';}

(Given that the path templates/sfunc.php is correct)

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download