ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

FCKeditor and double clicking

October 23, 2007 1:20pm

Subscribe [3]
  • #1 / Oct 23, 2007 1:20pm

    greygoose

    17 posts

    I see in the code for the fckeditor extension where it adds the ondblclick event to trigger the loading of the editor, but can anyone tell me how to make the editor load then the page loads? I tried using window.onload with no success. What seemed strange is that the window.onload event never fired at all.

  • #2 / Oct 23, 2007 4:07pm

    greygoose

    17 posts

    Well I found out a quick way to hack cp.publish.php to get what I wanted. If anyone is interested just let me know.

  • #3 / Oct 24, 2007 7:45am

    kingdoz

    45 posts

    i’m interested 😊

    please post the solution here if you wouldn’t mind!

  • #4 / Oct 24, 2007 11:17am

    greygoose

    17 posts

    Sure, no problem. This is more of a hack than anything else but here you go. You only need to edit two files (ext.fckeditor.php and cp.publish.php)

    Edit the fckeditor extension file, ext.fckeditor.php, in your extensions folder (/system/extensions/ext.fckeditor.php) and remove the javascript onclick and ondblclick calls on or near line 81. The onclick event isn’t used anyway and looks to be leftover code. The ondblclick event is what triggers the editor to show up so we want to get rid of that call.

    Change this:

    $r =  $DSP->input_textarea('field_id_'.$fieldID, $field_data, $rows, 'textarea', '100%','onclick="setFieldName(this.name);" ondblclick="setFieldName2(this.name);"', $convert_ascii);

    to this:

    $r =  $DSP->input_textarea('field_id_'.$fieldID, $field_data, $rows, 'textarea', '100%','', $convert_ascii);

    Next, edit cp.publish.php, found in /system/cp/cp.publish.php, around line 531. This is the <body> onload call stuff that we need to add. You can change this section to change all the text fields into fckeditors, or just a selected one. For this example I’ll just show how to change one specific textarea info the fckeditor. To do this, you’ll need to find out what id EE is assigning the field you want to change. The field will have a name and id similar to “field_id_4”. EE seems to randomly assign the ids so the only way to see what the id is, is to view the source of the publish page to find it. Note that if you change field later on that you might need to change the id here too.

    Change this:

    $DSP->body_props .= ' onload="document.forms[0].title.focus();set_catlink();" ';

    to this:

    $DSP->body_props .= ' onload="document.forms[0].title.focus();set_catlink();setFieldName2(\\'field_id_4\\');" ';

    That should do it. If you want to replace all the textareas on the publish page with fckeditors, you’d want to check out http://wiki.fckeditor.net/ReplaceAllTextareas. In cp.publish.php you would change the onload call to

    $DSP->body_props .= ' onload="document.forms[0].title.focus();set_catlink();setFieldName2();" ';
    and then in the setting for the FCKeditor extension (CP Home›Admin›Utilities›Extensions Manager) change the configuration to use the code found on the fckeditor wiki page
    // replace all of the textareas
    var allTextAreas = document.getElementsByTagName("textarea");
    for (var i=0; i < allTextAreas.length; i++) {
    var oFCKeditor = new FCKeditor( allTextAreas[i].name ) ;
    oFCKeditor.BasePath = "/FCKeditor/" ;
    oFCKeditor.ReplaceTextarea() ;

    Note that I’ve kept the function name setFieldName2 from the original extension file, but I would personally change it to something more descriptive like makeFCKeditor although this isn’t necessary.

  • #5 / Oct 03, 2008 1:04pm

    ROCKET MEDIA

    153 posts

    I could not seem to get this to work. The page will simply not load FCK. I noticed your code is missing the ending }.

    I am trying to replace all text areas with FCK. The link you provided does not work. Can you past your solution?

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases