PHP in page content

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
User avatar
thomahawk
Power Poster
Power Poster
Posts: 312
Joined: Fri Jul 25, 2008 10:13 am

PHP in page content

Post 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
nockenfell
Power Poster
Power Poster
Posts: 751
Joined: Fri Sep 12, 2008 2:34 pm

Re: PHP in page content

Post 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
User avatar
thomahawk
Power Poster
Power Poster
Posts: 312
Joined: Fri Jul 25, 2008 10:13 am

Re: PHP in page content

Post 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
nockenfell
Power Poster
Power Poster
Posts: 751
Joined: Fri Sep 12, 2008 2:34 pm

Re: PHP in page content

Post 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.
jmcgin51
Power Poster
Power Poster
Posts: 1899
Joined: Mon Jun 12, 2006 9:02 pm

Re: PHP in page content

Post 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.
Post Reply

Return to “CMSMS Core”