I have embedded PHP inside my html documents. When I use the editor, the php is not present.
Here is my html doc that loads the editor:
I have tried using include(), htmlspecialchars(file_get_contents()), file_get_contents(), and readfile(). Each of these 4 php functions bring the full html document, with the php intact, into the editor except for the htmlspecialchars(file_get_contents()) function.
Here is a browser "view source" look at the results of the editor load:
When I click the Source button on the Editor, here is what I get:
You see that my php tags are gone.
Has anyone used the FCK Editor to edit html documents that have php embedded? Can the editor handle and retain the php?
I am not looking to have the editor do any parsing -- wouldn't expect that capability out of the editor. But I do need an editor that will retain php code.
Thanks
Here is my html doc that loads the editor:
<form method="post"> <p> <textarea name="editor1"><?=file_get_contents('myDoc.html')?></textarea> <script type="text/javascript"> CKEDITOR.replace('editor1'); </script> </p> <p><input type="submit" value="Submit" /></p> </form>
I have tried using include(), htmlspecialchars(file_get_contents()), file_get_contents(), and readfile(). Each of these 4 php functions bring the full html document, with the php intact, into the editor except for the htmlspecialchars(file_get_contents()) function.
Here is a browser "view source" look at the results of the editor load:
<form method="post"> <p> <textarea name="editor1"><div class="block width_510"> <h3>Finance Office Home Page</h3> <p class="dateline"><?php echo date('l, F jS, Y'); ?></p> <p><?=K_PLACEHOLDER_TEXT?><span class="fullstory">Full story…</span></p> <h3>Second Post</h3> <p class="dateline"><?php echo date('l, F jS, Y'); ?></p> <p><?=K_PLACEHOLDER_TEXT?><span class="fullstory">Full story…</span></p> <h3>Third Post</h3> <p class="dateline"><?php echo date('l, F jS, Y'); ?></p> <p><?=K_PLACEHOLDER_TEXT?><span class="fullstory">Full story…</span></p> </div> </textarea> <script type="text/javascript"> CKEDITOR.replace('editor1'); </script> </p> <p><input type="submit" value="Submit" /></p> </form>
When I click the Source button on the Editor, here is what I get:
<div class="block width_510"> <h3> Finance Office Home Page</h3> <p class="dateline"> </p> <p> <span class="fullstory">Full story…</span></p> <h3> Second Post</h3> <p class="dateline"> </p> <p> <span class="fullstory">Full story…</span></p> <h3> Third Post</h3> <p class="dateline"> </p> <p> <span class="fullstory">Full story…</span></p> </div>
You see that my php tags are gone.
Has anyone used the FCK Editor to edit html documents that have php embedded? Can the editor handle and retain the php?
I am not looking to have the editor do any parsing -- wouldn't expect that capability out of the editor. But I do need an editor that will retain php code.
Thanks
Re: PHP tags and code not appearing in Editor
Remove the call to see how your textarea really looks like.
The simplest solution is to use the PHP integration as it should help you to generate the correct code.
Re: PHP tags and code not appearing in Editor
That's pretty close, but I do need the editor back.
Re: PHP tags and code not appearing in Editor
Can you help me better understand what that is and how to do it. I am an FCKEditor newbie and this is my first install.
Re: PHP tags and code not appearing in Editor
For example:
This will output the right thing (generally). Also, look into the full body html editing mode. That might be causing you problems too, but I haven't dealt with that really. It's one of the sample files called "Full page support (editing from <html> to </html>)" and relates to the fullPage config above I tossed in.
Re: PHP tags and code not appearing in Editor
Re: PHP tags and code not appearing in Editor
Where do I go to look into that?
Re: PHP tags and code not appearing in Editor
I think I understand what you're trying to do now. You want to literally be able to edit a php file as source code. The problem with this is that it will often cause the server to execute the PHP as it reads it in. It seems you've addressed this problem by getting the source code out. So to debug this follow these steps.

1) store file_get_contents to a variable and dump the result. It should be the source code. If not, you have to look into different ways to access the code
2) Use the php bootup I posted earlier to load a CKEditor instance. Make sure that works before you try to load the text in.
3) Load the text in ($cktext var in my example). See what happens. Make sure you've added the protected source variable as I specificed in your other post , otherwise some PHP code will get eaten.
4) Don't start multiple threads for the same issue
Re: PHP tags and code not appearing in Editor
Sorry...I actually know better.

Yesterday I registered to the community forum and posted the issue. The forum looked like it was pretty active. I didn't get a response from anyone all day long, so I sent a message to info (at) cksource.com hoping to get someone to help me (I am in the midst of installing the editor and I don't want to get too far down the path only to learn that this is the wrong editor to be using. I did a higher level eval between FCKEditor and TinyMCE, which I do have experience with, and elected to go with FCKEditor for its relative lighter weight footprint and better UI for my users).
This morning my post dropped way down the stack with no response. So I registered for another FCKEditor forum out there and made a more detailed post based on some php function tests I ran over night. Then I realized that forum was pretty inactive...last reply to a post was January I think. So I copied and pasted my post from that forum back here under a new thread in hopes to get some help. Well I got help, but muddied up the forum with a 2nd post.
So now on to trying what you are recommending. I'll do my best to pull it together -- working on no FCKEditor experience here.
Oh, and one last thing for the webmaster to CKSource, FCKEditor and this community forum. The 3 sites (from my perspective) don't tie together well. I know at one point I saw some developer documentation. But for the life of me I can't seem to navigate back to it. No need to post a link here...the bigger issue is that usability and accessibility between with sites could use a little tweaking.
Re: PHP tags and code not appearing in Editor
Did that. Produced the same exact results that I documented at the top of this thread using the file_get_contents() function.
So troubleshooting step #1 passed.
On to step #2
Re: PHP tags and code not appearing in Editor
I assume the following code is what you mean:
Now I just need to figure out where to place this and how. Any tips are greatly appreciated and will help reduce the "spinning my wheels" time.
Re: PHP tags and code not appearing in Editor
If you want to stick with your original approach however, I think you should focus on the solution I posted in your other topic, which I'll now repost here for google's sake.
look into protectedsource. I.E. in your config (Which could also be the PHP if you end up using that) add
Note that I just made this up, and I'm pretty sure some of the escapes on the regex are wrong. But basically this array will not process anything inside the matching regex, so everything inside your php tags would only exist in source view. IE
would show as such in source view, but as
blah blah
in wysiwyg view.You could even buff the thing to support short tags with somthing like:
Let me know if that helps! (You can try it in the original mode first before playing with calling the editor from PHP)
Re: PHP tags and code not appearing in Editor
Re: PHP tags and code not appearing in Editor
Is there or is there not a solution to this problem?
After spending several hours, searching dozens of links on this forum, I have come up with nothing that works!
Every time I enter
It is deleted
by the editor!!!
Re: PHP tags and code not appearing in Editor
I will try to step through some of the suggestions and ideas made by the contributors to this post, but if anyone reading this has actually used CK Editor to edit and update web documents that contain HTML, PHP, inline CSS and embedded JavaScript tags within a web document, could you post your "how to make it work" comments here. Otherwise, comment that CK Editor is not capable of handling mixed-tag content inside the web doc.
Thanks, greatly appreciated.
Re: PHP tags and code not appearing in Editor
Tried this by adding to the config.js. No Success.
Has anyone out there used CKEditor with embedded PHP and successfully have the edit process retain the PHP?
Re: PHP tags and code not appearing in Editor
Basically the answer is
The problem is I need a simpler regex and, unfortunately, I do not know regex coding.
What might the regex look like for protecting an opening tag like this
<?
and protecting a closing tag like this?>
That's all I need to the regex to check for. There are a variety of uses in our web documents of the opening php tag like and
<?
and<?=
and and on and on...So does anyone have the regex for
<?
and?>
only? Thanks !!