views:

171

answers:

3

I can't seem to find a js RTE that will play friendly with snippets of php intertwined in it. I want a mini CMS for the backend of a number of sites. The views have some snippets of php here and there

Are there any RTE's that will leave the php alone, and even show it mixed with the nice formatting?

TinyMCE kills the tags even when entered in html mode and switched back and forth. FCKEdit seems to keep the code intact if pasted into source mode, but it isn't shown in the editing side, so if someone deletes an element with some php in it, bop, it's gone.

And none of the editors like creating nicely indented code, that would be a nice plus as well, but probably over the top to ask, heh.

+1  A: 

The Javascript rich text editors make use of the browsers' in-built DesignMode or ContentEditable features in order to implement in-line HTML editing, and these do not support embedded PHP tags.

The solution would have to convert these to some other form, which is not going to get mushed by the browser's HTML editor, then convert them back to PHP tags upon submission.

It could be done. I don't know of any that do, however.

As for creating nicely indented code, it is a similar issue. The browsers munge it in their in-line HTML editors.

thomasrutter
I thought that might be the case. I tried adding a <pre> before and after the tags: <pre><?php ?></pre> And was hoping I could mod the code to do a quick regex replace of "<pre><?php" to "<?php" upon saving, but it seems the RTE's don't play nice with <pre> either...
phazei
I think you are on the right track with <pre>. Did you try also escaping its contents as in <pre><?php ?></pre>? I have a feeling that _should_ be preserved by the browsers. I can't promise it though.
thomasrutter
A: 

I'm a php developer and have been using a javascript text to html editor for quite some years now. Real easy to do.

Al Toman
A: 

I had a similar question a few weeks back: http://stackoverflow.com/questions/1619167/textarea-that-can-do-syntax-highlighting-on-the-fly

This may be the right thing for you: http://marijn.haverbeke.nl/codemirror/ They even have mixed PHP and HTML highlighting.

Pekka