Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

TinyMCE stripping PHP and Script tag

Status
Not open for further replies.

tvchick2006

Programmer
Dec 5, 2007
3
US
Hi all,

We provide TinyMCE to users to edit their web files. I have recently noticed that TinyMCE strips PHP and Script tags from my file which causes JavaScript to work no longer or PHP code gets screwed.

Can this problem be fixed or should I start looking for a new editor.

Thanks
 
is it your intention that the php gets executed when the relevant page is displayed?
 
If I have a file phpinfo.php that says: <?php phpinfo(); ?> then I want to see expected result. But if I open the file using TinyMCE, write something and save the file. I no longer see the expected result. If I check the code - I see: <html>... phpinfo() </html>.

This happens with Javascript as well. if the <script> tag is in <body> then the editor just removes the <script></script> leaving everything in between.

So I would like Editor not to delete/remove tags and let them be as they are.
 
some authors are working on a plugin to enable this. at the moment the solution is a work around. instead of using <?php and ?> you should use something like ##php and php## for the tags. then in your code use this type of function before writing to the database

Code:
function makeExecutable($text){
 return str_replace(array('##php', 'php##'), array('<?php','?>'), $text);
}

and do the reverse before submitting the text back to the editor.

have a look at the tinymce wiki for further information
 
TinyMCE is a WYSIGWYG editor. Why would you be putting HTML in there?


You can extend the allowable tags by adding parameters to the initialisation script. This might get you past the <script> problem unless you can't over-ride them for security reasons. It's all in the documentation wiki.

--
Tek-Tips Forums is Member Supported. Click Here to donate

<honk>*:O)</honk>

Tyres: Mine's a pint of the black stuff.
Mike: You can't drink a pint of Bovril.


 
foamcow -

i use execphp as a plugin extensively in my wordpress blogs and wp uses tinymce as the post editor. in content management apps i think there is a genuine need for the bona fide inclusion of php code in pages.
 
i think there is a genuine need for the bona fide inclusion of php code in pages.

Fair enough, but does that need to be via a WYSIWYG interface?

I guess if you are using something like Wordpress and the editor is also used for conventional input then it's understandable.

--
Tek-Tips Forums is Member Supported. Click Here to donate

<honk>*:O)</honk>

Tyres: Mine's a pint of the black stuff.
Mike: You can't drink a pint of Bovril.


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top