Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Been searching around for a way to set default link target in the CKeditor link dialog box, but with no luck. Today the default setting is "not set", but the client want's it to be _blank.
It seems FCKeditor had a setting for this, but can't find anything similar for CKeditor. Have tried this based on the setting for FCK, but with no result:
function mymodule_wysiwyg_editor_settings_alter(&$settings, $context) {
if($context['profile']->editor == 'ckeditor') {
$settings['DefaultLinkTarget'] = '_blank';
}
}
Not possible?
Comment | File | Size | Author |
---|---|---|---|
#2 | ck-gone.png | 139.14 KB | vegardjo |
Comments
Comment #1
TwoDI looked through http://docs.cksource.com/ckeditor_api/symbols/CKEDITOR.config.html and the source of CKEditor's Link plugin,but can't find any option for that either.
However, I did find out how to emulate the behavior from FCKeditor. You'll need one custom Drupal module, and one custom CKEditor plugin. After that it'll be a piece of cake to reuse this on any site.
sites/all/modules/cdt/cdt.info:
sites/all/modules/cdt/cdt.module:
sites/all/libraries/ckeditor_plugins/default_target/plugin.js:
Enable the module and check the "Default link target" box under "Buttons and Plugins" and you're all set! :)
References:
Comment #2
vegardjo CreditAttribution: vegardjo commentedWow - best support answer ever, thanks a bundle! :)
Sadly I didn't quite get it to work. I enable the module, add the CK plugin and activate the plugin (and cleared cache), but the result of this is that the WYSIWYG won't load at all - the textfield is simply gone. If I deactivate the plugin again it's back. This on Drupal 7.8, admin theme Seven, WYSIWYG 2.1, CKEditor 3.6.1.7072
See screenshot. You will also see the
visibility: hidden
style there, if I remove this I see the actual textfield, but the WYSIWYG is still not loaded in it..Comment #3
TwoDThe original textarea is hidden by the editor as it uses an iframe for editing, but it looks like it did not load completely.
Can you check Firebug's Console tab for errors?
Also check the Net tab to make sure all files got downloaded properly (none are red).
The plugin file from sites/all/libraries/ckeditor_plugins/default_target/plugin.js should also show up in there.
Comment #4
vegardjo CreditAttribution: vegardjo commentedAah, my bad!
I placed the file in
sites/all/libraries/ckeditor/plugins/default_target/plugin.js
while it should be insites/all/libraries/ckeditor_plugins/default_target/plugin.js
so I placed it in the plugin directory to ckeditor, you in a separate plugin directory. Which also is smarter :)Thanks again for your help, it works like a charm now!
Comment #6
Mirroar CreditAttribution: Mirroar commentedAt least for the current version of ckEditor, you'll have to update the JavaScript a little. Otherwise, _blank will be selected in the link dialog box by default, but after clicking OK no target will be set anyway. The reason for this is the fact that ckEditor also checks the content of the linkTargetName field on submitting, and that value is usually set via the onChange-callback.
So here is an updated version of the JavaScript code which also calls the onChange-callback while setting up the dialog.
Comment #7
TwoDUpdated the code in #1 with the change from #6 and added a new default CSS Class feature from #1915198: Set default class to Colorbox in LINK dialog .
Comment #8
sayansk CreditAttribution: sayansk commentedEnable the module and check the "Default link target" box under "Buttons and Plugins" and you're all set!
The third day I struggle with this problem. I'm sorry, but I can not find the "Buttons and Plugins" ... Can you please tell me where to find them? In the settings CKEditor is no such :(
Comment #9
hugovk CreditAttribution: hugovk commentedThanks for this!
sayansk, find it somewhere like:
Modules -> Wysiwyg -> Configure -> CKEditor -> Edit -> BUTTONS AND PLUGINS -> Default link target