Support Forum

Advanced Search
Forum Scope


Match



Forum Options



Minimum search word length is 3 characters - maximum search word length is 84 characters
plugins-topic
Extend tinyMCE by plugins
Avatar
Dietmar Herian
Member
Free Members
sp_UserOfflineSmall Offline
Oct 4, 2012 - 8:18 am

Hi SP-team,

I was in need of having tablecontrols on the menu of tinymce plugin. So, I downloaded the table plugin from tinymce.com and put it into wp-content/sp-resources/forum-plugins/tinymce-richtext/tinymce/plugins.

But it did not work. As soon as I insert 'table' in the plugins line in settings, the editor stops working - just showing an empty area. Removing the 'table' setting brings back the usual function.

Is it a version conflict, maybe? (I just used the table plugin currently online on tinymce.com)

Or is it a matter of release?

How to do it correctly?

"Computers in the future may weigh no more than 1.5 tons."
(Popular Mechanics, US-Technik-Magazin, 1949)

Avatar
Mr Papa
Simi Valley, CA
SP Master
Free Members
sp_UserOfflineSmall Offline
Oct 4, 2012 - 11:22 pm

oh wow... could use Andy for this as the tinymce expert... but he is gone for couple weeks on vacation... so I will see if I can help...

yes, you can add plugins... first step is as you did to upload it... but now you have to tell tinymce that you have added a plugin...  and this is where I am trying to do this from memory...

you need to add a filter to your spFunctions.php file in your sp theme... something like:

add_filter('sph_mce_external_plugins', 'my_tinymce_plugin');
function my_tinymce_plugin($plugins) {
    $plugins[] = array('name' => 'http://url.to.plugin');
    return $plugins;
}

you will need to replace 'name' with the name of the plugin... and http://url.to.plugin with the url to the plugin js file..

you may also have to add a button to the forum - components - tinymce button list to get it to show up...

so give that a try and lets see where we get...

Avatar
Dietmar Herian
Member
Free Members
sp_UserOfflineSmall Offline
Oct 5, 2012 - 4:02 am

Seems to be more behind it!

I tried to include the above sample code into my theme's spFunctions.php, and the filter gets fired. I have just put in a debug message instead of the array modification to print_r the $plugins content and it turns out to be empty! Shouldn't there be the standard plugins in? Maybe, this is due to the 'external' ?

Do you really need to use an 'external' plugin? Essentially, the table plugin should be internal as it is uploaded to the standard plugin folder. Then just putting 'table' into the $plugins array should suffice. Maybe, there is an extra filter for 'internal' plugins?

For testing purposes, I also changed (temporarily) the install sequence in sp-tinymce-install.php adding 'table' to the plugins, de-activated and re-activared the plugin. Then I have put 'table' into TinyMEC Plugins line in admin settings and 'tablecontrols' into the PluginButtons1 line. But all I am getting are some 'graphical artefacts' in the place where the buttons should appear.

  gr_artefacts.png

Maybe, there are some CSS issues behind that needs to be corrected to support the table buttons. Should we suspend this question until Andy is back?

"Computers in the future may weigh no more than 1.5 tons."
(Popular Mechanics, US-Technik-Magazin, 1949)

Avatar
Mr Papa
Simi Valley, CA
SP Master
Free Members
sp_UserOfflineSmall Offline
Oct 5, 2012 - 9:54 am

no, the $plugins would be empty... unless you added other plugins..  its a list of user added plugins, hence external in the name...  any plugins that we include in the tinymce plugin itself would not be in the list as they are not user added or external...

you are reading far too much into the name...  tinymce has an init file that has to load any plugins... tinymce does not scan directories for plugins... you have to list them in the init file... and since you dont want to be editing the plugin file to add your plugin, we give you a filter to add it to the list...  so anyone who adds a plugin via that filter will get it loaded too...  external = user added...

which is what you did...  but by using the filter, you dont have to edit the init file...

so please show me the code you added to your spFunctions.php file...

and give me a link to the plugin itself so I can download it and try to add it on one of my test sites...

Avatar
Dietmar Herian
Member
Free Members
sp_UserOfflineSmall Offline
Oct 5, 2012 - 11:12 am

o.K. did it this way. Please see the code below, I've put into my spFunctions. For testing purposes, I am always using absolute URLs to make sure I am on the right track. dbg_r() is my own function for var_dump the variable in my format.

It obviously does something but not the right thing - now the area of tinyMCE remains empty while loading the editor. Removing the filter brings up the tinyMCE again. Doing both, using the filter and settings line, yields the same empty editor area.

Btw, the same happens if you simply put in 'table' into the 'TinyMCE plugins' settings line in admin without running through the filter. And more: I added the 'emotions' and 'xhtmlxtras' plugins the same way and they worked out-of-the-box.

 

tiny_xtras.pngImage Enlarger

 

function my_tinymce_plugin($plugins) {
//    $plugins[] = array('name' => 'http://url.to.plugin');
    $plugins[] = array('table'=> 'http://5.9.51.145/wp-content/sp-resources/forum-plugins/tinymce-richtext/tinymce/plugins/table');
    wp_mail('dietmar@herian.de', 'tinyMCE_table_dbgr', dbg_r($plugins));
    return $plugins;
}

Here is the link  tinyMCE 3.5.7 to the version I took the plugin from. It downloads as full package including all plugins.

"Computers in the future may weigh no more than 1.5 tons."
(Popular Mechanics, US-Technik-Magazin, 1949)

Avatar
Mr Papa
Simi Valley, CA
SP Master
Free Members
sp_UserOfflineSmall Offline
Oct 5, 2012 - 12:45 pm

will try to look further this weekend...

but why dont you try this filter:

sph_add_tm_plugin

instead...  I am as new to this as you!  Andy is Mr Tinymce for us... ;)

dump out the passed in plugins arg... you might just be able to add in table to that array...

Avatar
Mr Papa
Simi Valley, CA
SP Master
Free Members
sp_UserOfflineSmall Offline
Oct 5, 2012 - 12:54 pm

yup..works for me...

apply_filters('sph_add_tm_plugin', 'mytm');
 function mytm($plugins) {
     $plugins[] = 'table';
     return $plugins;
 }

and then add it to forum - components - tinymce plugin list and buttons...

Avatar
Mr Papa
Simi Valley, CA
SP Master
Free Members
sp_UserOfflineSmall Offline
Oct 5, 2012 - 2:45 pm

btw, I can get the plugin to load using the external stuff too... but it doesnt seem to work as the plugin appears to be written with the expectation that its loaded in in the tinymce plugin directory which is unfortunate...

for reference, to load an external plugin (assuming plugin was located in sp-resources folder):

add_filter('sph_mce_external_plugins', 'mytm');
function mytm($plugins) {
    $plugins['table'] ='http://yoursite.com/wp-content/sp-resources/table/editor_plugin.js';
    return $plugins;
}

and then add it to the plugin list and buttons...

Avatar
Dietmar Herian
Member
Free Members
sp_UserOfflineSmall Offline
Oct 5, 2012 - 4:34 pm

Did everything as layed out - but still getting empty editor area with both methods. I believe, I have an incompatibility here in the install or need to install the table plugin new.

I'll try it first on my test site. Will take some days.

Thanks for great help!

"Computers in the future may weigh no more than 1.5 tons."
(Popular Mechanics, US-Technik-Magazin, 1949)

Avatar
Mr Papa
Simi Valley, CA
SP Master
Free Members
sp_UserOfflineSmall Offline
Oct 5, 2012 - 5:58 pm

Odd. The non external worked fine. Could you post your code? And the changes you made on forum - components - tinymce

Forum Timezone: Europe/Stockholm
Most Users Ever Online: 1170
Currently Online:
Guest(s) 1
Top Posters:
Mr Papa: 19448
Ike: 2086
Brandon: 864
kvr28: 804
jim: 650
FidoSysop: 577
Conrad_Farlow: 531
fiddlerman: 358
Stefano Prete: 325
Member Stats:
Guest Posters: 619
Members: 17363
Moderators: 0
Admins: 4
Forum Stats:
Groups: 7
Forums: 17
Topics: 10127
Posts: 79625