Hi,
I want to be able to load an external html file into FCKditor. I can save it fine, but I am having trouble getting the content loaded into the editor.
And... I am not getting any errors.

This is what I have so far....

HTML FILE

<html>
<head>
<title>Editor</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<script type="text/javascript" src="/fck/fckeditor/fckeditor.js"></script>
</head>
<body>

[B][COLOR="red"]<?php 
include "read01.php";
?>[/COLOR][/B]

<form action="save01.php" method="post" target="_blank">
<script type="text/javascript">
var oFCKeditor = new FCKeditor('FCKeditor1');
oFCKeditor.BasePath = "/fck/fckeditor/";
[COLOR="Red"][B]oFCKeditor.Value = $sValue;[/B][/COLOR]
oFCKeditor.Create();
</script>
<br>
<input value="Submit" type="submit">
</form>

</body>
</html>

PHP FILE

<?php
$filename = 'sample01.htm';

if (!$handle = fopen($filename, 'r')) {
	 echo "$sValue=File did not load.";
	 exit;
}

$sValue = file_get_contents ($filename);
//echo $sValue;
?>

The editor doesn't load because the "oFCKeditor.Value = $sValue;" line in the html is not returning the value correctly.

But, if I do it like this (oFCKeditor.Value = "Some plain old hard-coded text string")
It will load the text and display the editor.

So... I am not sure if I am passing the contents of the html file from the PHP file, into the html correctly.

Any help would be appreciated.
🙂

    your missing quote marks around the file contents, unless they happen to be in the file itself.

      dagon;10892417 wrote:

      your missing quote marks around the file contents, unless they happen to be in the file itself.

      To test if my PHP include statement is returning the contents.
      I echoed the $sValue in the php include statement... it will print out the html in the html editor file.

      So, that means my read01.php file does return the contents of the sample01.htm file.

      I tried to do this, but loads the sytnax into the FCKE.
      oFCKeditor.Value = ' & $sValue & ';

      I don't think that I have the quotes correctly. Remember, the "oFCKeditor.Value" parameter is inside a FORM in the editor html.

      🙂

        $sValue= '"' . preg_replace("/[\r\n]+/",'" + $0"',addslashes($sValue)) . '"';

        ...

        oFCKeditor.Value = ' . $sValue . ' ;

        this what i use, its pulling data from a db but same issue, also your $sValue is outside a php block so will never work

          This is what my external PHP (read01.php) file returns if I echo it in my html editor source code.

          <p>This is <strong>some</strong> of <span style="font-size: x-large"><span style=""><strong><span style="color: #ff0000">our text</span></strong></span></span></p>

          Now if I can just get it into the "oFCKeditor.Value = $sValue" statement of my form.

          🙂

            dagon;10892429 wrote:

            $sValue= '"' . preg_replace("/[\r\n]+/",'" + $0"',addslashes($sValue)) . '"';

            ...

            oFCKeditor.Value = ' . $sValue . ' ;

            this what i use, its pulling data from a db but same issue, also your $sValue is outside a php block so will never work

            If my $sValue is outside my block, then how do I get into the $sValue of the form?
            I am returning a value that doesn't need any stripping does it?

            🙂

              So... how do I set up my html editor html file to work properly?

              edit01.htm

              <?php 
              include "read01.php";
              echo $sValue;
              ?>
              
              <form action="save01.php" method="post" target="_blank">
              <script type="text/javascript">
              var oFCKeditor = new FCKeditor('FCKeditor1');
              oFCKeditor.BasePath = "/fck/fckeditor/";
              oFCKeditor.Value = $sValue;
              oFCKeditor.Create();
              </script>
              <br>
              <input value="Submit" type="submit">
              </form>
                <?php 
                include "read01.php";
                $sValue= '"' . preg_replace("/[\r\n]+/",'" + $0"',addslashes($sValue)) . '"';
                //may not need all of above line
                ?>
                
                <form action="save01.php" method="post" target="_blank">
                <script type="text/javascript">
                var oFCKeditor = new FCKeditor('FCKeditor1');
                oFCKeditor.BasePath = "/fck/fckeditor/";
                
                <?php
                echo "oFCKeditor.Value = $sValue" ;
                ?>
                
                oFCKeditor.Create();
                </script>
                <br>
                <input value="Submit" type="submit">
                </form>
                

                  Oh my... it works!!!

                  I have to use the below line or it will not work.

                  $sValue= '"' . preg_replace("/[\r\n]+/",'" + $0"',addslashes($sValue)) . '"';

                  Can you explain to me what the above line is doing?
                  I know they are dealing with line breaks... but how is this handling slashes?
                  I didn't see any slashed in the echoed output that I tested to see what i was passing.

                  Thanks You!!

                  🙂

                    Write a Reply...