New 6.x-2.x is in dev, providing several hooks to extend CKEditor Link.
These hooks allow to add support for other internal paths than the initial node paths.
CKEditor Link 6.x-2.x will have built-in support for links to:
- nodes
- menu items
- taxonomy terms
Any developer who wants to work to add support for links to other internal paths is welcome.
This can be either as a patch or as a separate module.
The different hooks are presented in the ckeditor_link.api.php file.
Help to improve this file/documentation would be highly appreciated too.
I'll be adding some basic documentation about how to extend CKEditor Link here.
The corresponding 7.x-2.x-dev will be added soon.
Comments
Comment #1
anrikun commentedHow to extend CKEditor Link?
Handling other internal paths
Any module that wants to handle other internal paths should declare "types" by implementing
hook_ckeditor_link_types().Type names can be anything (it has to be machine-readable names though): it is just a way to tell CKEditor Link that the implementing module wants to handle new internal paths.
A good practice is to use the names of the modules you want to support the paths of: for instance, CKEditor Link itself declares 'node', 'menu' and 'taxonomy' as types.
Altering existing types handling
Any module that wants to change the way existing types are handled can implement
hook_ckeditor_link_types_alter().Providing autocomplete suggestions
CKEditor Link invokes the
hook_ckeditor_link_TYPE_autocomplete()hook on every declared TYPE.So, for instance, if you want to handle views paths, and have declared a 'views' type, you may implement
hook_ckeditor_link_views_autocomplete()to return autocomplete suggestions to user.Altering autocomplete suggestions
Before suggestions are returned to the user, any module gets the chance to alter them by implementing
hook_ckeditor_link_autocomplete_alter().Reverting previously entered paths
Then user edits an existing internal link, CKEditor Link invokes the
hook_ckeditor_link_TYPE_revert()hook on every declared TYPE.You should implement this hook to revert any existing path handled by your module to its human-readable title.
CKEditor Link Filter: converting raw internal paths into URL aliases
The CKEditor Link Filter invokes
hook_ckeditor_link_TYPE_url()on every TYPE. You should implement this hook to convert paths handled by your module into URL aliases.Adding settings to the CKEditor Link settings form
6.x-2.x now has a settings form at
admin/settings/ckeditor_link. You can implementhook_ckeditor_link_TYPE_settings()to easily add settings to this form (hook_form_alter() can be used too though).Comment #2
joostvdl commentedsubscribe
Comment #3
dankh commentedsubscribe
Comment #4
anrikun commentedNew 7.x-2.x is in dev, in sync with 6.x-2.x.
Comment #5
anrikun commentedNew 6.x-2.0-rc1 and 7.x-2.0-rc1 are out!
I will update this page soon to provide better documentation about the hooks.
Comment #6
anrikun commentedI have just updated hooks documentation at #1.
Comment #7
knalstaaf commentedI'd like the user to be able to set a path to a page that was created and placed in the menu through Views ("Link to View").
I believe this is the given instruction to achieve this:
I've opened the
ckeditor_link.api.phpfile (in Drupal 7.8), but since I'm not a techie it's not really clear to me what has to happen there. Could you go a little more in detail please? The italic bold phrases in the blockquote sound a bit mysterious to me :)Comment #8
anrikun commentedNo programming is necessary here.
As CKEditor Link natively supports linking to menu item paths, menu items added through Views should show up too, as long as you have enabled menus to be available as autocomplete suggestions from CKEditor Link's settings page. Have you?
Comment #9
knalstaaf commentedThanks! That's exactly where I got lost apparently: the menus weren't checked.
I went to admin/config/content/ckeditor_link, as described in the
README.txt, and checked Any menu right beneath "Menu items".Works fine now.
Comment #10
pbeakley commentedSo I just tried to use the Link editor to build a link to a menu item, which is a taxonomy term generated by the Taxonomy Menu module. Autosuggested the correct link but it wouldn't validate as a "valid internal link." :-/ Thoughts?
Comment #11
anrikun commented@pbeakley:
Please post this as a separate Support request and provide the path of the link that doesn't validate.
Comment #12
devin carlson commentedThe extensibility of CKEditor Link is much appreciated.
Comment #13
anrikun commentedI guess this should be moved to a real documentation page.
In the meantime, let's leave it open so that developers can find it easily.
Comment #14
crealosophy commentedTried to implement the hook_ckeditor_link_TYPE_url() for my content type "study", so I included the following function in my custom module, here for reference named cusmo:
This has no effect whatsoever. I implemented hooks from other modules before, but this does not work. I have no clue what is happening. Could someone help me?
Comment #15
anrikun commentedHave you implemented
hook_ckeditor_link_types()too?You need to declare your TYPE there.
Please read #1