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!
PHP code in template
PHP code in template
Last edited by giggler on Tue Oct 09, 2007 7:18 am, edited 1 time in total.
-
liudaz
Re: PHP code in template
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
Try using "User defined tags". This is where i put all my php code and than call it in template with {whatever}.
Cheers!
liudaz
-
calguy1000
- Support Guru

- Posts: 8169
- Joined: Tue Oct 19, 2004 6:44 pm
Re: PHP code in template
to use {php}echo "hello world";{/php} you have to enable_php_tags (or something like that) in config.php
Follow me on twitter
Please post system information from "Extensions >> System Information" (there is a bbcode option) on all posts asking for assistance.
--------------------
If you can't bother explaining your problem well, you shouldn't expect much in the way of assistance.
Please post system information from "Extensions >> System Information" (there is a bbcode option) on all posts asking for assistance.
--------------------
If you can't bother explaining your problem well, you shouldn't expect much in the way of assistance.
Re: PHP code in template
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
['use_smarty_php_tags']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
I believe in UDT you don't need the {php} calls...
-
calguy1000
- Support Guru

- Posts: 8169
- Joined: Tue Oct 19, 2004 6:44 pm
Re: PHP code in template
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.
i.e:
Code: Select all
echo 'hello world'; Follow me on twitter
Please post system information from "Extensions >> System Information" (there is a bbcode option) on all posts asking for assistance.
--------------------
If you can't bother explaining your problem well, you shouldn't expect much in the way of assistance.
Please post system information from "Extensions >> System Information" (there is a bbcode option) on all posts asking for assistance.
--------------------
If you can't bother explaining your problem well, you shouldn't expect much in the way of assistance.


