PHP in content or templates

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
Hollywood
Forum Members
Forum Members
Posts: 10
Joined: Thu May 17, 2007 3:58 am

PHP in content or templates

Post by Hollywood »

I'd like to use PHP to conditionally include files in my templates and content.  Is this possible -- inserting PHP code in templates or content records a la:

User avatar
Nullig
Power Poster
Power Poster
Posts: 2380
Joined: Fri Feb 02, 2007 4:31 pm
Location: Comox Valley, BC

Re: PHP in content or templates

Post by Nullig »

Your config.php must be edited to include:

Code: Select all

#Allow smarty {php} tags?  These could be dangerous if you don't trust your users.
$config['use_smarty_php_tags'] = true; <--this has to be set to true 
Nullig
Hollywood
Forum Members
Forum Members
Posts: 10
Joined: Thu May 17, 2007 3:58 am

Re: PHP in content or templates

Post by Hollywood »

Hmm... I did this and reloaded the page with the PHP code in the template, and I'm still not seeing the code that the PHP renders appear.  Do I need to do something else to get it to appear?
calguy1000
Support Guru
Support Guru
Posts: 8169
Joined: Tue Oct 19, 2004 6:44 pm
Location: Fernie British Columbia, Canada

Re: PHP in content or templates

Post by calguy1000 »

once 'use_smarty_php_tags' is turned on in your config.php
you need to surround the php code with {php} and {/php} instead of


i.e:

Code: Select all

{php}phpinfo();{/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.
Post Reply

Return to “CMSMS Core”