Page 1 of 1
PHP code in template
Posted: Tue Oct 09, 2007 7:11 am
by giggler
Is there a way to add PHP code inside the template? I've tried the following since this is using smarty and didn't work, All it did was print out the "code here", but did not execute the code:
{php}code here{/php}
Thanks!
Re: PHP code in template
Posted: Tue Oct 09, 2007 9:29 am
by liudaz
Hi!
Try using "User defined tags". This is where i put all my php code and than call it in template with {whatever}.
Cheers!
liudaz
Re: PHP code in template
Posted: Tue Oct 09, 2007 2:27 pm
by calguy1000
to use {php}echo "hello world";{/php} you have to enable_php_tags (or something like that) in config.php
Re: PHP code in template
Posted: Wed Oct 10, 2007 5:26 am
by giggler
Thanks Calguy, it was this code to true and worked in the template (but will not work in the content pages, which is fine):
I first tried the the user defined tags and got the following error:
Code: Select all
# Parse error: syntax error, unexpected '}' in /var/www/admin/edituserplugin.php(105) : eval()'d code on line 1
Re: PHP code in template
Posted: Wed Oct 10, 2007 9:56 pm
by Dr.CSS
I believe in UDT you don't need the {php} calls...
Re: PHP code in template
Posted: Wed Oct 10, 2007 10:02 pm
by calguy1000
A UDT is a function, therefore you don't need the { and } characters at the start and end
i.e:
is a perfectly valid UDT.