Ability to change location of Buttons and add separators

SeanBannister - September 17, 2007 - 04:20
Project:TinyMCE WYSIWYG Editor
Version:5.x-1.x-dev
Component:User interface
Category:feature request
Priority:normal
Assigned:Unassigned
Status:active
Description

It would be great if you provided functionality via drupal to change the order of the buttons, add separators and linebreaks.

#1

markus_petrux - November 2, 2007 - 10:26

Hi,

I also needed to achieve this, and did the following.

1) Edit tinymce.module and find function tinymce_config()

2) Before the line that reads "$min_btns = 5; // Minimum number of buttons per row." insert the following snippet:

//+MOD: Order buttons as described in plugin_reg.php
      $old_buttons = array();
      $new_buttons = array();
      for ($i=1; $i <= 3; $i++) {
        $new_buttons[$i] = array();
        $old_buttons[$i] = $init['theme_advanced_buttons'. $i];
      }
      for ($i=1; $i <= 3; $i++) {
        $tmp_buttons = $plugins['default']['theme_advanced_buttons'. $i];
        foreach ($tmp_buttons as $tmp_button) {
          for ($j=1; $j <= 3; $j++) {
            $k = array_search($tmp_button, $old_buttons[$j]);
            if ($k !== false && !in_array($tmp_button, $new_buttons[$i])) {
              $new_buttons[$i][] = $tmp_button;
              $old_buttons[$j][$k] = null;
              break;
            }
          }
        }
      }
      for ($i=1; $i <= 3; $i++) {
        $old_buttons[$i] = array_filter($old_buttons[$i]);
        if (count($old_buttons[$i]) > 0) {
          foreach ($old_buttons[$i] as $k => $tmp_button) {
            $new_buttons[$i][] = $tmp_button;
          }
        }
        $init['theme_advanced_buttons'. $i] = $new_buttons[$i];
      }
//-MOD: Order buttons as described in plugin_reg.php

3) Select which buttons you wish from TinyMCE profile settings, as usual.

4) Edit the file plugin_reg.php and move the following lines to the top of function _tinymce_plugins() and configure them as desired:

$plugins['default'] = array();
$plugins['default']['theme_advanced_buttons1'] = array(...);
$plugins['default']['theme_advanced_buttons2'] = array(...);
$plugins['default']['theme_advanced_buttons3'] = array(...);

Hope that helps.

 
 

Drupal is a registered trademark of Dries Buytaert.