PHP code in template

For questions and problems with the CMS core. This board is NOT for any 3rd party modules, addons, PHP scripts or anything NOT distributed with the CMS made simple package itself.
Post Reply
giggler
Forum Members
Forum Members
Posts: 197
Joined: Tue Oct 09, 2007 7:08 am

PHP code in template

Post 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!
Last edited by giggler on Tue Oct 09, 2007 7:18 am, edited 1 time in total.
liudaz

Re: PHP code in template

Post 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
calguy1000
Support Guru
Support Guru
Posts: 8169
Joined: Tue Oct 19, 2004 6:44 pm

Re: PHP code in template

Post by calguy1000 »

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.
giggler
Forum Members
Forum Members
Posts: 197
Joined: Tue Oct 09, 2007 7:08 am

Re: PHP code in template

Post 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):

Code: Select all

['use_smarty_php_tags']
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 
User avatar
Dr.CSS
Moderator
Moderator
Posts: 12711
Joined: Thu Mar 09, 2006 5:32 am

Re: PHP code in template

Post by Dr.CSS »

I believe in UDT you don't need the {php} calls...
calguy1000
Support Guru
Support Guru
Posts: 8169
Joined: Tue Oct 19, 2004 6:44 pm

Re: PHP code in template

Post by calguy1000 »

A UDT is a function, therefore you don't need the { and } characters at the start and end

i.e:

Code: Select all

echo 'hello world'; 
is a perfectly valid UDT.
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.
Post Reply

Return to “CMSMS Core”