brian2000 wrote:what do you mean it eats your php?
can you post your code
What I mean is, if I enter php into the ckeditor and save, it comes back without the php.
the textarea is populated with htmlentities() on the text, and when submitted to the db html_entity_decode() is run. It works with a standard textbox, but the CKEditor takes out the php tags.
I tried putting it in after the CKEDITOR.replace( 'body' ); and in the config.js file inbetween the brackets. Neither seemed to have any effect.
I also have another question- I have some custom tags I use for a BBCode like setup, they're for includes that bring in other templates, and CKEDITOR likes to put <p> tags, which if the include is for <html><head> etc, having <p> before <html> is bad.
Where can I control the <p> tags, or do I need to do some fancy coding to undo them?
<p>
[include(.header)]</p>
<p>
My body</p>
<p>
[include(.footer)]</p>
Thanks for your help!
EDIT/Update: copied config.js up a directory from the ckeditor directory, seems to work there- but the code in the PHP tags is invisible unless in source mode. Is there anything I can do to make them visible? EDIT2: looks like the posted text has more or less what I'm looking for, but the reload into CKEditor puts the <p> tags around, so re-saving then breaks. EDIT3: setting it to come up in source mode preserves the lack of <p>'s until I leave and re-enter source mode. - but of course the php code is still invisible in non source and get's the p tags when I come back. EDIT4: seems to be eating my doctype, html, head, and meta tags- how do I keep those?
I am also looking for the same solution. I added the config.protectedSource.push( /<\?[\s\S]*?\?>/g ); // PHP Code on the very last line of config.js. However it eats up my php code i enter in the source code editor. Has anybody found a solution to get this to work at all?
UPDATE: I posted this under an existing thread about FCKeditor 2 because it seemed like the most relevant thread, but this solution is meant for CKeditor 3. I haven't actually tested it with FCKeditor 2. -------
Alright, I think I figured out how to scale shahidmau's function. Using this modification, you can now enter as many different PHP code snippets as you want into the source view of CKeditor. Each snippet is interpreted (evaluated) by PHP and rendered as such.
The main difference is that preg_match_all is used instead of preg_match and most of the variables are now arrays. The preg_replace function is also limited to one (1) replacement per iteration.
I'm not a PHP-guru by any means (!), so please offer modifications to make this more efficient etc.
Re: CKEditor + PHP Code
can you post your code
Re: CKEditor + PHP Code
What I mean is, if I enter php into the ckeditor and save, it comes back without the php.
the textarea is populated with htmlentities() on the text, and when submitted to the db html_entity_decode() is run. It works with a standard textbox, but the CKEditor takes out the php tags.
Re: CKEditor + PHP Code
CKEDITOR.config.protectedSource
Re: CKEditor + PHP Code
I also have another question- I have some custom tags I use for a BBCode like setup, they're for includes that bring in other templates, and CKEDITOR likes to put <p> tags, which if the include is for <html><head> etc, having <p> before <html> is bad.
Where can I control the <p> tags, or do I need to do some fancy coding to undo them?
If I put in:
I get:
Thanks for your help!
EDIT/Update: copied config.js up a directory from the ckeditor directory, seems to work there- but the code in the PHP tags is invisible unless in source mode. Is there anything I can do to make them visible?
EDIT2: looks like the posted text has more or less what I'm looking for, but the reload into CKEditor puts the <p> tags around, so re-saving then breaks.
EDIT3: setting it to come up in source mode preserves the lack of <p>'s until I leave and re-enter source mode. - but of course the php code is still invisible in non source and get's the p tags when I come back.
EDIT4: seems to be eating my doctype, html, head, and meta tags- how do I keep those?
Re: CKEditor + PHP Code
Thanks in advance,
Al
Re: CKEditor + PHP Code
Re: CKEditor + PHP Code
Re: CKEditor + PHP Code
Beddengoed webshop
Re: CKEditor + PHP Code
$fileData = htmlentities(file_get_contents("FILE LOCATION HERE"));Re: CKEditor + PHP Code