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
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
Here's the documentation:
http://docs.fckeditor.net/FCKeditor_2.x ... ration/PHP
Simply assign value pulled from DB to $oFCKeditor->Value.
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
My php script calls a template in html,
so when I retrieve the value from the database, I'm in php,
but the editor itself is within an html template file.
Here is the portion of the php code that prepares an editor for each language :
foreach ($aLangues as $vLangue)
{if (isset($aDICT[$vLangue]))
{$vCodeDICT = $aDICT[$vLangue]['CodeDICT'];
$vTexte = preparer($aDICT[$vLangue]['valeur']);}
else
{$vCodeDICT = '';
$vTexte = '';}
$bData['{aLangue}'] = $vLangue;
$bData['{zLangue}'] = auLong('all_langues',$vLangue,'valeur');
$bData['{zHiddenField}'] = '<INPUT TYPE="hidden" NAME="CodeDICT_' . $vLangue . '" VALUE="' . $vCodeDICT . '">';
$bData['{zTexte}'] = addslashes($vTexte);
$vHTML .= strtr($aTemplate[1],$bData);}
$vHTML .= strtr($aTemplate[2],$aData);}}
Here is the template file :
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<HTML>
<HEAD>
<TITLE>FDLT</TITLE>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
<LINK HREF="outils/style.css" REL="stylesheet" TYPE="text/css">
<script type="text/javascript" src="../../fckeditor/fckeditor.js"></script>
<script type="text/javascript">
function FCKeditor_OnComplete(editorInstance)
{editorInstance.Events.AttachEvent('OnBlur', FCKeditor_OnBlur);
editorInstance.Events.AttachEvent('OnFocus', FCKeditor_OnFocus);}
function FCKeditor_OnBlur(editorInstance)
{editorInstance.ToolbarSet.Collapse();}
function FCKeditor_OnFocus(editorInstance)
{editorInstance.ToolbarSet.Expand();}
</script>
</HEAD>
<BODY BGCOLOR="#FFFFFF" BACKGROUND="../images/fond.gif">
£
<TABLE WIDTH="100%" BORDER="0" CELLPADDING="5" CELLSPACING="1">
<TR>
<TD VALIGN="bottom">Section : {zSection} - Page : {zPage}</TD>
<TD VALIGN="bottom" ALIGN="right">{zActions}</TD>
</TR>
~
<TR><TD COLSPAN="2" BGCOLOR="#999999" CLASS="TitrePetitPale">{aLabel}</TD></TR>
<TR><TD COLSPAN="2" BGCOLOR="#FFFFFF" CLASS="Normal">{zData}</TD>
</TR>
~
<TR>
<TD COLSPAN="2" VALIGN="bottom" ALIGN="right">{zActions}</TD>
</TR>
</TABLE>
£
<FORM ACTION="a_repartiteur.php" METHOD="post" NAME="Formulaire">
<INPUT TYPE="hidden" NAME="vOption" VALUE="editeur">
<INPUT TYPE="hidden" NAME="vSection" VALUE="{zSection}">
<INPUT TYPE="hidden" NAME="vPage" VALUE="{zPage}">
<INPUT TYPE="hidden" NAME="vAction" VALUE="{zAction}">
<INPUT TYPE="hidden" NAME="vApres" VALUE="{zApres}">
<INPUT TYPE="hidden" NAME="CodeTXT" VALUE="{zCodeTXT}">
<TABLE WIDTH="100%" BORDER="0" CELLPADDING="5" CELLSPACING="1">
<TR>
<TD VALIGN="bottom">Section : {zSection} - Page : {zPage}</TD>
<TD VALIGN="bottom" ALIGN="right">{zActions}</TD>
</TR>
~
<TR><TD COLSPAN="2" BGCOLOR="#999999" CLASS="TitrePetitPale">{aLabel}</TD></TR>
<TR><TD COLSPAN="2" BGCOLOR="#FFFFFF" CLASS="Normal">
{zHiddenField}
<script type="text/javascript">
<!--
oFCKeditor = new FCKeditor('Texte_{aLangue}');
oFCKeditor.Config['ToolbarStartExpanded'] = true;
oFCKeditor.BasePath = '../../fckeditor/';
oFCKeditor.ToolbarSet = 'Short';
oFCKeditor.Value = '{zTexte}';
oFCKeditor.Create();
//-->
</script>
</TD>
</TR>
~
<TR>
<TD COLSPAN="2" VALIGN="bottom" ALIGN="right">{zActions}</TD>
</TR>
</TABLE>
</FORM>
£
</BODY>
</HTML>
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:
My code with data from database:
Hope this helped.
Re: Problems with loading the value from a previous FCKEditor sa