I have some smarty php code:
in my sample.tpl file:
{require_once(test.php)}
{php}
echo test();
{/php}
and in my test.php file:
<?php
function test(){
return "hi";
}
?>
For some reason, this breaks the entire template and does not work. Also note that {php} echo "hi" {/php}
works fine.
Ultimately, I just need to run code attached to a button. If there's an easy way to do this in smarty (eg. an if statement or something), let me know.
You normally don't need to use require
or require_once
inside Smarty, a function available in the scope of the caller script (which loaded the template) should be available in the template too...