Hi
I have a problem reloading the value I saved with a previous FCKEditor into another FCKEditor from a Database.\
Here are the step I take:
Saving
-Add content to editor
-Save content to database
Modifying
-Get content from database
-load content into editor <------THIS STEP DOES NOT WORK.
I get an error of Unterminated String Literal although the string is terminated. The data I'm trying to load is HTML from the FCKEditor and the carriage returns / line breaks seems to cause the error. Here is the code:
The rendered HTML looks like:
and this causes the error of Unterminated String Literal.
Please help!
Francois
I have a problem reloading the value I saved with a previous FCKEditor into another FCKEditor from a Database.\
Here are the step I take:
Saving
-Add content to editor
-Save content to database
Modifying
-Get content from database
-load content into editor <------THIS STEP DOES NOT WORK.
I get an error of Unterminated String Literal although the string is terminated. The data I'm trying to load is HTML from the FCKEditor and the carriage returns / line breaks seems to cause the error. Here is the code:
<script type="text/javascript">
<!--
// Automatically calculates the editor base path based on the _samples directory.
// This is usefull only for these samples. A real application should use something like this:
// oFCKeditor.BasePath = '/fckeditor/' ; // '/fckeditor/' is the default value.
var sBasePath = document.location.pathname.substring(0,document.location.pathname.lastIndexOf('/fckeditor/_samples')) ;
var oFCKeditor = new FCKeditor( 'description' ) ;
oFCKeditor.BasePath = sBasePath ;
oFCKeditor.Width = 455 ;
oFCKeditor.Height = 300 ;
oFCKeditor.Value = "<? echo rtrim(str_replace('"',"'", $row["description"])); ?>";
oFCKeditor.Create() ;
//-->
</script>The rendered HTML looks like:
<script type="text/javascript">
<!--
// Automatically calculates the editor base path based on the _samples directory.
// This is usefull only for these samples. A real application should use something like this:
// oFCKeditor.BasePath = '/fckeditor/' ; // '/fckeditor/' is the default value.
var sBasePath = document.location.pathname.substring(0,document.location.pathname.lastIndexOf('/fckeditor/_samples')) ;
var oFCKeditor = new FCKeditor( 'description' ) ;
oFCKeditor.BasePath = sBasePath ;
oFCKeditor.Width = 455 ;
oFCKeditor.Height = 300 ;
oFCKeditor.Value = "<p>fsdfdsf</p>
<p>fsdf</p>
<p>fsdfsdf</p>
<p>fsdfsdfsdf</p>
<p>fsdfsdfsdfdsfdsf</p>
<p> </p>
<p> </p>
<p><strong>fsdfsdfsdfsdfsdfsdfsdffsddfs</strong></p>";
oFCKeditor.Create() ;
//-->
</script>and this causes the error of Unterminated String Literal.
Please help!
Francois

Re: Problems with loading the value from a previous FCKEditor sa
<script type="text/javascript"> <!-- // Automatically calculates the editor base path based on the _samples directory. // This is usefull only for these samples. A real application should use something like this: // oFCKeditor.BasePath = '/fckeditor/' ; // '/fckeditor/' is the default value. var sBasePath = document.location.pathname.substring(0,document.location.pathname.lastIndexOf('/fckeditor/_samples')) ; var oFCKeditor = new FCKeditor( 'description' ) ; oFCKeditor.BasePath = sBasePath ; oFCKeditor.Width = 455 ; oFCKeditor.Height = 300 ; oFCKeditor.Value = "<p>fsdfdsf</p>\ <p>fsdf</p>\ <p>fsdfsdf</p>\ <p>fsdfsdfsdf</p>\ <p>fsdfsdfsdfdsfdsf</p>\ <p> </p>\ <p> </p>\ <p><strong>fsdfsdfsdfsdfsdfsdfsdffsddfs</strong></p>"; oFCKeditor.Create() ; //--> </script>or... simply use PHP Api.
Wiktor Walc
CTO, CKSource - http://cksource.com
--
Follow CKEditor on: Twitter | Facebook | Google+
Re: Problems with loading the value from a previous FCKEditor sa
what function of PHP should I use?
Thank you.
--William
Re: Problems with loading the value from a previous FCKEditor sa
http://docs.fckeditor.net/FCKeditor_2.x ... ration/PHP
Wiktor Walc
CTO, CKSource - http://cksource.com
--
Follow CKEditor on: Twitter | Facebook | Google+
Re: Problems with loading the value from a previous FCKEditor sa
Reading one of the previous posts, I figured that the problem I had was that each line has to be terminated with a backslash, so I wrote the following function and it solved my problem. I put it here in case it helps someone else.
function preparer($vTexte)
{$aTexte = explode("\n",$vTexte);
for ($i=0;$i<count($aTexte)-1;$i++)
{$aTexte[$i] .= '\\';}
return implode("\n",$aTexte);}
and later when I get the value from the database :
$vTexte = preparer($row->Texte);
and later when I build the FCKeditor instance :
oFCKeditor.Value = <?php echo $vTexte; ?>
Serge Grenier
Re: Problems with loading the value from a previous FCKEditor sa
If you use the PHP integration, it will take care of the lines for you.
Re: Problems with loading the value from a previous FCKEditor sa
Re: Problems with loading the value from a previous FCKEditor sa
Re: Problems with loading the value from a previous FCKEditor sa
Default code with value set to straight text:
<?php $oFCKeditor = new FCKeditor('html'); $oFCKeditor->BasePath = 'fckeditor/'; $oFCKeditor->Value = "I Like cheese!"; $oFCKeditor->Create(); ?>My code with data from database:
<?php $oFCKeditor = new FCKeditor('html'); $oFCKeditor->BasePath = 'fckeditor/'; include ("Link to database file"); $query = "SELECT * FROM pages WHERE id = $id"; $result = mysql_query($query); while ($row = @mysql_fetch_array($result, MYSQL_ASSOC)) { $oFCKeditor->Value = "{$row['html']}"; } $oFCKeditor->Create(); ?>Hope this helped.
Re: Problems with loading the value from a previous FCKEditor sa
function fixLineBreaks($txt) { return str_replace("\r\n", "\\\n", $txt); } $oFCKeditor->Value = fixLineBreaks($myvalue);