Preface:Updated a bit on Sept. 10/06This successful integration of FCKEditor with sNews began while looking for a solution to AgniZ's problem trying to use Javascript to get FCKEditor running with sNews. His problem is
outlined here. I didn't have any luck with the JS Integration, so I took at look at the PHP Integration. What follows is a
short version to get you started with
PHP Integration, adding the FCKEditor Panel to the new_article and edit_article functions in snews.php. I
MAY put a full tutorial on snews.ca if I decide to spend some time learning to 'streamline' FCKEditor.
However... sNews 1.5 (RC version) is now out for testing to us all... and has enhanced features that may make this add-on less useful in the end.
I should note that I have no interest in using FCKEditor myself, as I am fairly comfortable with using HTML mark-up in-line while composing articles. I only offer these "tips" to help anyone else get started with FCKEditor... nothing more. If you choose to work with FCKEditor, you will need to figure it out pretty much on your own... so be ready for an adventure! Check out the official
FCKEditor documentation for PHP Integration. Keep .txt logs of what you do while you fiddle and mod, so you can always back out of an unsuccessful move. The following assumes you've already downloaded and un-zipped FCKEditor.
Step 1:If you are uploading directly to your remote (host) server, upload the FCKeditor folder into the root of your website directory... the same location where your index.php and snews.php files are. If you are installing this within an offline (localhost) server, just copy and paste the folder into the sNews 1.4 site's root folder.
Before modding - backup your snews.php file!!Step 2 - Modding snews.php: There are 5 textareas in snews.php, in
function comment, contact, new_article, edit_article and
edit_comment. The mod steps are essentially the same for each function, but I'll only deal with new_article and edit_article here to keep it short. So... open snews.php in a good code editor.
In function new_article - just under the first line, add:
include("FCKeditor/fckeditor.php"); // includes functions to display FCKEditor textarea.
The above line needs to be inserted at the start of any function in which you choose to replace the default sNews textara. Now... in the same function, scroll down and find this line which creates the default sNews textarea:
<p><textarea name="text" class="text"><? echo $_SESSION['temp']['text']; ?></textarea>
and replace it with the following lines:
<?
echo "<p>";
$oFCKeditor = new FCKeditor('text') ;
$oFCKeditor->BasePath = 'FCKeditor/';
$oFCKeditor->Value = $_SESSION['temp']['text'];
$oFCKeditor->Create() ;
echo "</p>";
?>
In function edit_article - just under the first line, add the same include line we added to the new_article function above. Then scroll down and find this line which (again) creates the default sNews textarea... in the Edit Article Admin Panel:
<p><textarea name="text" class="text"><? echo stripslashes($text); ?></textarea></p>
and replace it with the following lines:
<?
echo "<p>";
$oFCKeditor = new FCKeditor('text') ;
$oFCKeditor->BasePath = 'FCKeditor/';
$oFCKeditor->Value = stripslashes($text); // includes the article text to be edited in the textarea
$oFCKeditor->Create() ;
echo "</p>";
?>
Step 3: Create a new folder in the root of your site called
UserFiles. When you create new folders using the FCKEditor Image upload feature, it will put the new folders within this new folder.
Step 4 - PHP ActivationFCKEditor has 'engine' files to run it in several different code-modes. Since we are using the PHP Integration... in the fckconfig.js file... lines 134 and 135...
we need to change the
code language settings from 'asp' to 'php'. This enables the php system for file browsing and uploading. So change the lines on the ends from:
var _FileBrowserLanguage = 'asp' ;
var _QuickUploadLanguage = 'asp' ;
so they look like this:
var _FileBrowserLanguage = 'php' ;
var _QuickUploadLanguage = 'php' ;
Then, you need to open the config.php file in the FCKeditor/editor/filemanager/upload/php folder.
- Scroll down to line 24... to $Config['Enabled'] = false ; and change false to true.
Then you need to do the same in the config.php file in the
FCKeditor/editor/filemanager/browser/default/connections/php folder, on line 24.
And... believe it or not... that's all you need to do to get the FCKEditor package functioning in your sNews 1.4 site. The real fun starts once you have it working... lots to learn... to figure out... etc. Documentation on how it works and how to use it is, in my view, a bit sparce. But there are sample files and some documentation files within the FCKEditor package for you to browse and ponder over. Remember, using add-ons like this requires experimentation and patience, as you must learn by doing.
