We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 15086
    • 13 Posts
    <?php echo "Hello world!"; ?>

    I’m here ’cause I am having a little problem with FCKE in MODx.
    I would change a little the FCKE’s configuration but I want to ensure that this new config will be kept even if the MODx version changes (ie on a MODx update).

    For the moment I have modified plugins/fckeditor/fckconfig.js but I think it’s not really safe (in my opinion) => I have to be sure the modifications are kept.
    Secondly, by editing the FCKConfig.CustomConfigurationsPath variable in the above file, my value is overwritten by this code:
    <script language='javascript' type='text/javascript'>var oFCKta = new FCKeditor('ta');oFCKta.Width = '100%';oFCKta.Height = '400';oFCKta.BaseHref = 'http://www.neutrik-france.com/';oFCKta.BasePath = '/assets/plugins/fckeditor/';oFCKta.Config['ImageBrowser'] = true;oFCKta.Config['ImageBrowserURL'] = FCKImageBrowserURL;oFCKta.Config['LinkBrowser'] = true;oFCKta.Config['LinkBrowserURL'] = FCKLinkBrowserURL;oFCKta.Config['FlashBrowser'] = true;oFCKta.Config['FlashBrowserURL'] = FCKFlashBrowserURL;oFCKta.Config['SpellChecker'] = 'SpellerPages';oFCKta.Config['CustomConfigurationsPath'] = '/assets/plugins/fckeditor/custom_config.js';oFCKta.ToolbarSet = 'advanced';oFCKta.Config['EditorAreaCSS'] = FCKEditorAreaCSS;oFCKta.ReplaceTextarea();</script>

    more precisely this instruction:
    oFCKta.Config['CustomConfigurationsPath'] = '/assets/plugins/fckeditor/custom_config.js';


    I managed to find the code which include those affectations (and any more), and I identified that in file manager/actions/dynamic/mutate_content.dynamic.action.php:
    <?php 
    
    /**
     *	Initialize RichText Editor 
     *  orig MODIFIED BY S.BRENNAN for DocVars
     * 
     */ 
    if($content['type']=="document" || $_REQUEST['a']==4) {
    	if(($content['richtext']==1 || $_REQUEST['a']==4) && $use_editor==1) {
    		if(is_array($replace_richtexteditor)) {
    			// invoke OnRichTextEditorInit event
    			$evtOut = $modx->invokeEvent("OnRichTextEditorInit", // line 1082
    											array(
    												editor 		=> $which_editor,
    												elements	=> $replace_richtexteditor
    											));
    			if(is_array($evtOut)) echo implode("",$evtOut); // line 1087 => echo the JavaScript which overwrite my variable
    		}
    	}
    }
    ?>


    But here I need some help...
    Where do $modx->invokeEvent("OnRichTextEditorInit", ...) gets its content? Is there a way to surely modify the path to a personal FCKE’s config file? (I didn’t see it in the MODx administration)
    Thanks.
      • 4018
      • 1,131 Posts
      Look in the FCKEditor directory under assets/plugins. You should see a file called custom_config.js. This is probably the best way to add in any custom configuration parameters to FCKEditor. This allows for adding global changes to any instance of FCKEditor. Certainly better than hacking the code. smiley
        Jeff Whitfield

        "I like my coffee hot and strong, like I like my women, hot and strong... with a spoon in them."
        • 15086
        • 13 Posts
        OK, actually it is what I did first but I wanted to create an other custom config file.
        My idea was to modify the path to the custom file and everything would be OK. But the path is overwritten by
        oFCKta.Config['CustomConfigurationsPath'] = '/assets/plugins/fckeditor/custom_config.js';
        If I know where this setting is registered, I may find the way to set it to my own file.
        So if anyone has an idea of where this variable is set...
          • 4018
          • 1,131 Posts
          It’s set in the fckeditor.functions.php file. Basically there’s multiple lines that sets the configuration for each instance of FCKEditor ($fckInstances). Should be pretty straightforward I think. Just keep in mind that if you change it and then upgrade the editor that you’ll have to go back in and change it again. Personally, I would just stick with the default custom_config.js file and edit it to your hearts content. Much easier to upgrade than the functions file. wink
            Jeff Whitfield

            "I like my coffee hot and strong, like I like my women, hot and strong... with a spoon in them."