Hi all,
I am using the PHP4 implementation of FCKeditor version 2.6 Build 18638 with FireFox version 3.0.3 on a WAMP box. My configuration's FullPage attribute is set to true. Whenever I try to display contents of an PHP file in the WYSIWYG, it strips out the html xmlns attribute and random new line characters around the PHP code. This results in the page failing XHTML compliance and throwing a PHP fatal error.
Here's the contents of the PHP file:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta content="text/html; charset=ISO-8859-1" http-equiv="Content-Type" /> <title>Welcome to my site!</title> </head> <body> <table cellspacing="0" cellpadding="0" border="0" align="center" style="width: 729px;"> <tbody> <tr> <td> <?php // see sample usage: admin > tools > widgets; require_once('lib/PageContent.class.php'); $wpage = new PageContent(); $wpages = $wpage->getActiveList(); if(count($wpages)>0){ ?> <div id="widgetContents">Widget code goes here</div> <?php } ?>##SHOPPING CART## </td> </tr> </tbody> </table> </body> </html>
The PHP file displays a very simple XHTML compliant page with some dynamic content generated with PHP. I triple checked the integrity of the contents when they are read from files in PHP using file_get_contents(). I am certain that there is no problem at this point. I tinkered with the fckeditor_php4.php file that displays the editor and figured out that the "Render the linked hidden field" hidden input has correct contents in it. However, when the iframe of the editor loads, here's what it contains:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" /> <title>Welcome to my site!</title> </head> <body> <table cellspacing="0" cellpadding="0" border="0" align="center" style="width: 729px;"> <tbody> <tr> <td><?php // see sample usage: admin > tools > widgets; require_once('lib/PageContent.class.php'); $wpage = new PageContent(); $wpages = $wpage->getActiveList(); if(count($wpages)>0){ ?> <div id="widgetContents">Widget code goes here</div> <?php } ?>##SHOPPING CART##</td> </tr> </tbody> </table> </body> </html>
There are two huge problems here:
1) <html xmlns="http://www.w3.org/1999/xhtml"> in the original content becomes <html>
2) The PHP code gets squished to one line and since there's a comment line, it causes a fatal error because the opening { is now commented out
<?php // see sample usage: admin > tools > widgets; require_once('lib/PageContent.class.php'); $wpage = new PageContent(); $wpages = $wpage->getActiveList(); if(count($wpages)>0){ ?>
becomes
<?php // see sample usage: admin > tools > widgets; require_once('lib/PageContent.class.php'); $wpage = new PageContent(); $wpages = $wpage->getActiveList(); if(count($wpages)>0){ ?>
I have been working on this problem for 2 days straight now. Any suggestions/help (at all) would be greatly appreciated.
Re: Editor strips out xmlns attribute and new lines
Hey all again,
I figured it out (sorta). The main problem was that my server side code was being stripped out (well actually random chunks of it were lost in translation. I'm not sure how the WYSIWYG decided what to throw out and what to keep, but it made a huge mess) when I first started working on the project and to avoid that I simply tricked the WYSIWYG by replacing all my <?php tags with <?php before sending the content to the editor:
But that for some reason had radical effects on the contents when they were loaded in the WYSIWYG. The most noticeable issue was that most of my header content was nuked:
became
After many hours of struggling with the problem, I found this helpful page: http://docs.fckeditor.net/FCKeditor_2.x ... Source.Add but unfortunately since I'm using a PHP implementation, there was no way for me to easily call the JS function on the FCKConfig object. I had to hack the system a bit to fix it. Since the WYSIWYG is rendered through an iframe, I edited the HTML file where the frame pointed (/path/to/fck/editor/fckeditor.html) and added the function call in there after the object was declared:
That fixed almost all of my problems. The WYSIWYG was still eating the xmlns attribute of the html tag. I couldn't figure out what was going on there, so I simply did a PHP search replace once the page was submitted:
This has definitely been a very frustrating experience with an editor that's usually not too hard to work with. I really hope this post helps someone out there because I could find nothing about this problem when I first started on this project.