I have an old website (circa 2004) that has been using plain textareas in various post/get forms that handle the editing of news posts and event details. By request of the client, they have asked me to update these textareas with a word-type interface. That's where FCKEditor came into play! The site currently uses the Smarty template system in conjunction with php/mysql database. I am having a problem where the data from mysql is being posted correctly, but not displayed. I have been through about 30+ pages of forum search results to no avail.
Here's the original a_editevent.tpl textareas:
And here is the relevant part of the new a_editevent.tpl with the FCK Editor markup:
And here is the editevent.php file which drives the form:
I believe there is something wrong with my syntax for FCKEditor's $oFCKeditor->Value setting inside of this Smarty template file. As you can see, {$shortdesc} worked in the textarea to retrieve and set the value for editing when using a plain textarea, however, I cannot find the magical combo of syntax to make this work using FCKEditor. Any help would be most appreciated, as I would love to get this working for them!
Thanks,
Ray
Here's the original a_editevent.tpl textareas:
{$header} <table border="0" cellpadding="2" cellspacing="0" id="ntbase"> <form action="editevent.php" method="POST" enctype="multipart/form-data"> <snip> <tr><td valign="top"><b>Short description:</b></td><td><textarea name="shortdesc" rows=3 cols=50>{$shortdesc}</textarea></td></tr> <tr><td valign="top"><b>Long description:</b></td><td><textarea name="longdesc" rows=10 cols=50>{$longdesc}</textarea></td></tr> <snip> {$footer}
And here is the relevant part of the new a_editevent.tpl with the FCK Editor markup:
<tr><td valign="top"><b>Short description:</b></td> <td width="435"> {php} $oFCKeditor = new FCKeditor('shortdesc'); $oFCKeditor->BasePath = '../fckeditor/'; $oFCKeditor->ToolbarSet = 'NT66'; $oFCKeditor->Value = $shortdesc; $oFCKeditor->Create(); {/php} </td></tr> <tr><td valign="top"><b>Long description:</b></td> <td width="435"> {php} $oFCKeditor = new FCKeditor('longdesc'); $oFCKeditor->BasePath = '../fckeditor/'; $oFCKeditor->ToolbarSet = 'NT66'; $oFCKeditor->Value = $longdesc; $oFCKeditor->Create(); {/php} </td></tr>
And here is the editevent.php file which drives the form:
<? require_once('users.inc'); require_once('init.php'); <snip> // Form submission if ($editp || $_POST['editp_x'] || $new_event) { $shortdesc = addslashes($shortdesc); $longdesc = addslashes($longdesc); $name = addslashes($name); $start = strftime("%Y-%m-%d %T",mktime($start_Hour,$start_Minute,0,$start_Month,$start_Day,$start_Year)); $end = strftime("%Y-%m-%d %T",mktime($end_Hour,$end_Minute,0,$end_Month,$end_Day,$end_Year)); $open = ($open == "on") ? 1 : 0; <snip> if ($new) $smarty->assign('new',1); else { // grab news info $info = mysql_query("select * f.r.o.m events where id=$id",$link); $grab = mysql_fetch_assoc($info); $grab['name'] = stripslashes($grab['name']); $grab['shortdesc'] = stripslashes($grab['shortdesc']); $grab['longdesc'] = stripslashes($grab['longdesc']); $grab['start'] = strtotime($grab['start']); $grab['end'] = strtotime($grab['end']); $smarty->assign($grab); } $smarty->display("a_editevent.tpl"); ?>
I believe there is something wrong with my syntax for FCKEditor's $oFCKeditor->Value setting inside of this Smarty template file. As you can see, {$shortdesc} worked in the textarea to retrieve and set the value for editing when using a plain textarea, however, I cannot find the magical combo of syntax to make this work using FCKEditor. Any help would be most appreciated, as I would love to get this working for them!
Thanks,
Ray
Re: PHP/MYSQL/Smarty + FCKEditor
Re: PHP/MYSQL/Smarty + FCKEditor
Re: PHP/MYSQL/Smarty + FCKEditor
Not really sure about this one but maybe this will help? http://www.smarty.net/manual/en/api.get.template.vars.php. I am just guessing that to set the value on the editor you might want to try
Assuming ofcourse that 'shortdesc' is a template assigned variable.
Re: PHP/MYSQL/Smarty + FCKEditor *solved*
By chance, I located the following site:
http://www.carloricohermoso.net/blogView.php?id=589
completing the steps on the above page helped me to get FCKEditor working correctly under php/mysql + smarty template system. The data is now pulled from the database into FCKEditor!
I hope this saves someone time in the future.