hi there,
i'm new to nicedit and was glad to find a lightweight rte for drupal 6. i installed the module following the install instructions (just copied the module-source into /modules and downloaded the editor itself into /modules/nicedit/nicEditor).
The only thing that appeared now was the three links ("show html"...). I had a closer look into the page source now and found that that nicEdit.js was not included into the page head (and not in the footer).
After looking around for some time i found out, that the hook_footer does not work properly when using drupal_add_js() in it. When printing out the JS-code directly, the editor works as expected.
I changed the function into that:
function nicedit_footer() {
global $base_path;
if ($textareas = _nicedit_set_textarea()) {
// include the nicEdit.js
$path = drupal_get_path('module', 'nicedit') .'/nicEditor';
if (file_exists(realpath($path .'/nicEdit.js'))) {
$output = '<script type="text/javascript" src="'.$base_path.'/'.$path.'/nicEdit.js"></script>';
}
else {
$output = '<script type="text/javascript" src="http://js.nicedit.com/nicEdit.js"></script>';
unset($path);
}
// write the javascript to create each editor object on each textarea
/**
* HELP: saving the nicEditor with the jquery element isn't working.
* This needs to be done so that we can reference it in nicedit-enable.js
* so we can update the values when switching between html and the editor.
*/
$js = array();
$page = $_GET['q'];
foreach ($textareas as $element_id) {
$name = substr($element_id, strpos($element_id, '-') + 1);
$all_settings = _nicedit_get_js_settings($page, $name, $path);
$js[] = 'try { $(\''. $element_id .'\').nicedit = new nicEditor({'. $all_settings .'}).panelInstance(\''. $element_id .'\') } catch(err) { }';
}
$output .= '<script type="text/javascript">bkLib.onDomLoaded(function() {'. implode(';', $js) .'})</script>';
return $output;
}
}
this code isn't tested far, but works for my installation. maybe it's useful for creating a clean workaround.
bye
schneck
| Comment | File | Size | Author |
|---|---|---|---|
| #2 | nicedit.patch | 1.09 KB | Schneck |
Comments
Comment #1
douggreen commentedThanks! But can you create a patch file, it's hard to tell what you changed - see Creating patches.
Comment #2
Schneck commentedok then, here's the patch. hope it works as expected.
Comment #3
jaimerodinstead of $base_path, use $base_url. So try
Notice how I spaced out the changed code and I put comments on the changes that I made.
Comment #4
douggreen commented