Page 1 of 1

PHP in page content

Posted: Thu Jun 16, 2011 9:01 am
by thomahawk
Hello all!

I need to place some php code inside the content of a page. But it always gets screwed up when saving.

I did deactivate WYSIWYG before pasting the code in. And I also used the {literate}{/literate} tags.

But it always takes the code out by placing <!-- in it.

How can I get this to work properly?
(And no, I could not find anything about this by searching the forum or google)

Regards,
Thomas

Re: PHP in page content

Posted: Thu Jun 16, 2011 9:40 am
by nockenfell
Activate php in your config.php

Code: Select all

#------------------
#Usability Settings
#------------------

#Allow smarty {php} tags?  These could be dangerous if you don't trust your users.
$config['use_smarty_php_tags'] = true;
use {php} your code {/php} in the content

Re: PHP in page content

Posted: Thu Jun 16, 2011 10:08 am
by thomahawk
Thank you for your quick answer, nockenfell.

So I understand it {literate} {/literate} is not necessary any more and {php} and {/php} replace the <?php and ?>, right?

And this goes the same in template as in page content?

Greetings,
Thomas

Re: PHP in page content

Posted: Thu Jun 16, 2011 10:56 am
by nockenfell
thomahawk wrote:Thank you for your quick answer, nockenfell.

So I understand it {literate} {/literate} is not necessary any more and {php} and {/php} replace the <?php and ?>, right?
correct.
And this goes the same in template as in page content?
i think so. but i'd never test this.

Re: PHP in page content

Posted: Thu Jun 16, 2011 3:49 pm
by jmcgin51
thomahawk wrote:Hello all!
I need to place some php code inside the content of a page. But it always gets screwed up when saving.
Unless you have a very compelling reason to actually put the PHP code in your actual page content, it would be better to put the PHP code in a UDT (without the <?php and ?> tags, and then call the UDT in your page content. Safer and harder to screw up.