Textareas on the panels content ui doesn't support WYSIWYG editors like FCKeditor

lourenzo - March 18, 2008 - 13:27
Project:Panels
Version:6.x-3.x-dev
Component:User interface
Category:bug report
Priority:critical
Assigned:Unassigned
Status:duplicate
Issue tags:Panels2, tinymce, WYSIWYG API
Description

I have FCKeditor working fine.
But when I create or edit custom content panes, FCKeditor doesn't show up, instead, two textareas are shown.

#1

merlinofchaos - March 18, 2008 - 16:52
Status:active» won't fix

This won't be fixable until Drupal 6; getting javascript to work in the popups requires a mechanism that doesn't exist in Drupal 5. Sorry.

#2

lourenzo - April 19, 2008 - 06:09

I've made it work, but it required a little hack that requires FCKEditor to be available.

Now, I'm trying to figure out how can it be reusable and support FCKEditor's absence, or even to deal with other WYSIWYG modules...

#3

merlinofchaos - April 19, 2008 - 21:02

Depending upon where your hack is, you might try the module_exists function to test for the presence of FCK editor; if you need to test this in javascript, have it put something in the settings?

#4

populist - July 29, 2008 - 06:04

I was able get WYSIWYG working with TinyMCE in a panel pane environment by doing a few modifications to the panel forms in form_alter. There are some limitations to the approach and it can be cleaned up a bit, but it can make it all happen in Drupal 5.x.

function my_module_form_alter($form_id, &$form) {
  switch($form_id) {
    case 'panels_edit_display':
      // Load a fake version of TinyMCE on the original page to get the javascript added
      $form['tinymce_hidden'] = array(
        '#type' => 'fieldset',
        '#attributes' => array('style' => 'display: none'),
      );
      $form['tinymce_hidden']['tinymce_prerender'] = array(
        '#type' => 'textarea',
      );
      break;
  
     case 'panels_content_config_form':
       // Modify the submit handler to save TinyMCE display to hidden textarea
       $form['next']['#attributes'] = array('onclick' => 'tinyMCE.triggerSave(true,true);');

       // Load a disable or enable link below each textarea
       global $user;
       $enable  = t('enable rich-text');
       $disable = t('disable rich-text');
       $user = user_load(array('uid' => $user->uid));
       $profile = tinymce_user_get_profile($user);
       $status = tinymce_user_get_status($user, $profile);
       $link_text = $status == 'true' ? $disable : $enable;
       foreach($form['configuration'] as $index_raw => $value) {
         $index = str_replace('_','-', $index_raw);
         if ($value['#type'] == 'textarea') {
           $form['configuration'][$index_raw]['#description'] .= "<div><a href=
\"javascript:mceToggle('edit-configuration-$index', 'wysiwyg4-configuration-$index');\" class=\"wysiwyg-editor\" title=\"edit-configuration-\"" . $index . "\" id=\"wysiwyg4-configuration-$index\">$link_text</a></div>";
         } else {
           if (is_array($value)) {
             foreach($form['configuration'][$index_raw] as $index2_raw => $value2) {
               $index2 = str_replace('_', '-', $index2_raw);
               if ($value2['#type'] == 'textarea') {
                 $form['configuration'][$index_raw][$index2_raw]['#description'] .= "<div><a href=\"javascript:mceToggle('edit-configuration-$index-$index2', 'wysiwyg4-configuration-$index-$index2'); \"  class=\"wysiwyg-editor\" title=\"edit-configuration-\"" . $index . '-' . $index2 . "\" id=\"wysiwyg4-configuration-$index-$index2\">$link_text</a></div>";
               }
             }
           }
         }
       }
      break;
  }
}

#5

jkpro3 - August 25, 2008 - 16:39

lourenzo: or anybody else

can you please share your hack for the panels pop-up window.. i need fckeditor to show up on the custom content pop-up but i can figure out how to do it.

Thanks in advance

#6

melezhik - February 12, 2009 - 23:47
Version:5.x-2.0-beta2» 5.x-2.0-rc1a
Priority:normal» critical
Status:won't fix» postponed (maintainer needs more info)

lourenzo, should you please figure out how did you hack it?

It would be very fine for me to repeat your experience and make FCKeditor available for editing custom content for group panel pages...

#7

mrfelton - February 16, 2009 - 16:33

is there a solution to this for D6/panels2 then?

#8

yasir farooqui - May 2, 2009 - 18:46

Thanks Man, your solution worked for me, However I needed it to be done in D6, so I modified a bit. Here is the modified version for D6.

function mymodule_form_alter(&$form, $form_state, $form_id) {

switch($form_id) {
case 'panels_edit_display_form':
      // Load a fake version of TinyMCE on the original page to get the javascript added
      $form['tinymce_hidden'] = array(
        '#type' => 'fieldset',
        '#attributes' => array('style' => 'display: none'),
      );
      $form['tinymce_hidden']['tinymce_prerender'] = array(
        '#type' => 'textarea',
      );
      break;
 
     case 'ctools_custom_content_type_edit_form':
      
// Modify the submit handler to save TinyMCE display to hidden textarea
       $form['buttons']['#attributes'] = array('onclick' => 'tinyMCE.triggerSave(true,true);');

       // Load a disable or enable link below each textarea
       global $user;
       $enable  = t('enable rich-text');
       $disable = t('disable rich-text');
       $user = user_load(array('uid' => $user->uid));
       $profile = tinymce_user_get_profile($user);
       $status = tinymce_user_get_status($user, $profile);
       $link_text = $status == 'true' ? $disable : $enable;
       foreach($form['body'] as $index_raw => $value) {
$index = str_replace('_','-', $index_raw);
if ($value == 'textarea') {

           $form['body']['#description'] .= "<div><a href=
\"javascript:mceToggle('edit-body', 'wysiwyg4-edit-body');\" class=\"wysiwyg-editor\" title=\"edit-body-\"" . $index . "\" id=\"wysiwyg4-edit-body\">$link_text</a></div>";
         } else {
           if (is_array($value)) {
             foreach($form['body'][$index_raw] as $index2_raw => $value2) {
               $index2 = str_replace('_', '-', $index2_raw);
               if ($value2['#type'] == 'textarea') {
                 $form['body'][$index_raw][$index2_raw]['#description'] .= "<div><a href=\"javascript:mceToggle('edit-configuration-$index-$index2', 'wysiwyg4-configuration-$index-$index2'); \"  class=\"wysiwyg-editor\" title=\"edit-configuration-\"" . $index . '-' . $index2 . "\" id=\"wysiwyg4-configuration-$index-$index2\">$link_text</a></div>";
               }
             }
           }
         }
       }
      break;
  }
}

#9

lord_of_freaks - May 3, 2009 - 22:47

Any solution for WYSWYG module in D6/Panels 2?????

#10

yasir farooqui - May 4, 2009 - 06:31

Hey the solution I posted is for drupal 6 + Panels2 + tinymce. Do you want to know some thing else?

#11

yasir farooqui - May 4, 2009 - 06:32

Hey the solution I posted is for drupal 6 + Panels2 + tinymce. Do you want to know some thing else?

#12

yasir farooqui - May 4, 2009 - 06:33

Sorry guys , I noticed that my I posted the same post twice.

#13

lord_of_freaks - May 4, 2009 - 13:43

<?php
function panels_tinymce_form_alter(&$form, $form_state, $form_id) {

   
   
// Choose your Input format. I choose Filtered HTML (1)
   
$format = 1;


    switch(
$form_id) {
        case
'panels_edit_display_form':
            
           
// Load a fake version of TinyMCE on the original page to get the javascript added
           
$form['tinymce_hidden'] = array(
               
'#type' => 'fieldset',
               
'#attributes' => array('style' => 'display: none'),
                    );
                   
$form['tinymce_hidden']['tinymce_prerender'] = array(
               
'#type' => 'textarea',
            );

           
$profile = wysiwyg_load_profile($format);
            
           
wysiwyg_add_editor_settings($profile,$profile->settings['theme']);
           
wysiwyg_load_editor($profile);

            break;

        case
'panels_content_config_form':
           
           
// Modify the submit handler to save TinyMCE display to hidden textarea
           
$form['next']['#attributes'] = array('onclick' => 'tinyMCE.triggerSave(true,true);');
            break;
    }
}
?>

#14

Dubber Dan - May 25, 2009 - 17:20

Hey Lorenzo, any chance of you posting your hack for FCKeditor?

If not then I guess I'll have to try the TinyMCE one instead.

#15

dkruglyak - May 31, 2009 - 12:46
Version:5.x-2.0-rc1a» 6.x-3.x-dev
Status:postponed (maintainer needs more info)» needs work

I suggest to consolidate separate TinyMCE / FCKeditor solutions into a single one based on WYSIWYG API module, intended as their replacement.

#16

sun - May 31, 2009 - 18:00
Status:needs work» duplicate

On an attempt to save merlinofchaos from such issues...

Marking as duplicate of #356480: Load Wysiwyg/libraries for AHAH forms and #350035: Implement Drupal.detachBehaviors(). You can follow up on that issue to track its status instead. If any information from this issue is missing in the other issue, please make sure you provide it over there.

However, thanks for taking the time to report this issue.

#17

Dubber Dan - June 4, 2009 - 15:56

The code by populist sounds promising, but I'm a little unsure where this code needs to be placed. Can anyone give some pointers?

#18

Dubber Dan - June 4, 2009 - 20:56

There's a good explanation of the code to get TinyMCE working on D5 to be found at http://www.chapterthree.com/blog/matt_cheney/howto_use_tinymce_panel_pan...

 
 

Drupal is a registered trademark of Dries Buytaert.