Hi,
I'm trying to write a simple module that enables a new tinymce plugin. I've put the plugin in my tinymce install location and my module calls the wysiwyg function hook_wysiwyg_plugin(). It works fine actually, but I'm a bit worried how I had to specify the location of my plugin.
Is there a wysiwyg api function (or drupal function) that will tell me where the tinymce library is installed? For me (and frankly everyone probably) it is in sites/all/libraries/tinymce, but I thought maybe there was a function like
wysiwyg_editor_path(tinymce) . 'jscripts/tiny_mce/plugins/[my plugin]'
Is there any such thing or do you have a suggestion as to the correct approach when writing modules that enable a tinymce plugin?
so I could do a
wysiwyg_editor_path(tinymce) .
Comments
Comment #1
meecect commentedugh, obviously I got my examples reversed...it should have said:
Is there a wysiwyg api function (or drupal function) that will tell me where the tinymce library is installed? For me (and frankly everyone probably) it is in sites/all/libraries/tinymce, but I thought maybe there was a function like
wysiwyg_editor_path(tinymce)
Is there any such thing or do you have a suggestion as to the correct approach when writing modules that enable a tinymce plugin?
so I could do a
wysiwyg_editor_path(tinymce) . 'jscripts/tiny_mce/plugins/[my plugin]'
Comment #2
twodYes, you should be able to use
wysiwyg_get_path($library_name, $bool_prepend_base_path)to get the path to the library folder actually used by the module. You could also use$editor['library path']where there is an editor object available. The library path is inserted into the array returned by the editor hooks for convenience.As you instruct your users to place the plugin in the editor's main plugin dir, you should also be able to skip the path key if you flag the plugin as internal by setting the key 'internal' to TRUE. This is not actually mentioned in the API docs, so I can't promise it will work in all future versions. In practice most editors default to using their internal plugin folder for plugins (or we explicitly set the path to be the internal plugin dir when encountering the 'internal' flag).
We hope to be able to switch to Libraries API for managing editors and plugins soon (3.x), then you can use that API instead.
Comment #3
meecect commentedThanks so much for the quick feedback. Again, I'm calling [mymodule]_wysiwyg_plugin($editor), so I guess that means the editor object is available. So could I do something like this (for the tinymce editor)?:
$path = $editor['library path'] . '/jscripts/tiny_mce/plugins/' . $mypluginname
Comment #4
meecect commentedActually, this seems to work fine:
$path = wysiwyg_get_path('tinymce') . '/jscripts/tiny_mce/plugins/[my plugin details]';
Thanks for the awesome help!!