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

lourenzo - March 18, 2008 - 13:27
Project:Wysiwyg
Version:6.x-2.x-dev
Component:Code
Category:feature request
Priority:critical
Assigned:Unassigned
Status:needs review
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...

#19

josegabriel.st - July 10, 2009 - 23:14

I've made work the WYSIWYG module for panels 2 using the code below:

<?php
 
foreach (filter_formats() as $format => $object) {
    if (
$profile = wysiwyg_get_profile($format)) {
     
wysiwyg_load_editor($profile);
     
wysiwyg_add_plugin_settings($profile);
     
wysiwyg_add_editor_settings($profile, 'default');
    }
  }
?>

Im using it in the hook_init of a custom module, sure there is a better way such as runing the code just in the panel_content page.

I havent tested it on Panels 3 yet.

Hope it helps!

--
Jose Sanchez
http://www.deviancefactory.com/

AttachmentSize
panels2-wysiwyg.png 105.07 KB

#20

recrit - July 13, 2009 - 23:25

drupal 6 + panels 6.x-3.0-beta2 + tinymce
This is a combination of the previous solutions with some tweaks.

<?php
function panels_tinymce_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',
          );

          foreach (
filter_formats() as $format => $object) {
            if (
$profile = wysiwyg_get_profile($format)) {
             
// wysiwyg_get_profile calls wysiwyg_load_editor

              // copied from wysiwyg.module
               
$theme = wysiwyg_get_editor_themes($profile, (isset($profile->settings['theme']) ? $profile->settings['theme'] : ''));
               
// Add plugin settings (first) for this input format.
               
wysiwyg_add_plugin_settings($profile);
               
// Add profile settings for this input format.
               
wysiwyg_add_editor_settings($profile, $theme);
             
// /copied from wysiwyg.module
           
}
          }

          break;

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

  }
// /switch $form_id

}
?>

#21

recrit - July 14, 2009 - 00:16

amendment to previous post to handle panel pages also.

<?php
 
switch($form_id) {
    case
'panels_edit_display_form':
    case
'panels_panel_context_edit_content':
         
// Load a fake version of TinyMCE on the original page to get the javascript added
        
...
?>

#22

pegleglax - September 25, 2009 - 15:52

Ugh....

This is difficult.

@recrit: Do I make a custom module or put this code in template.php? Do I need to have my profiles configured a certain way in WYSIWYG module or simply have the libraries for TinyMCE installed?

Thanks ^_^. Please leave as little as possible up to the imagination.

#23

recrit - September 29, 2009 - 01:29

WYSIWYG API + tinymce library
profiles do not have to be a certain way. This gets triggered on the panels edit form - if the user is privileged to select an input format that uses the WYSIWYG profile.

The above code needs to be put into a custom module.

#24

david.a.king - October 20, 2009 - 15:43

recrit -

couldn't get this to work (no effect whatsoever) when putting it in a custom module with d6, panels 3.1, wysiwyg with tinymce - am i doing something wrong?

#25

hefox - November 3, 2009 - 14:06

20, 21 in a module attached.

Works for me

AttachmentSize
panels_tinymce.zip 1.2 KB

#26

pvanthony - November 4, 2009 - 16:08
Version:6.x-3.x-dev» 6.x-3.2
Category:bug report» task
Priority:critical» minor
Status:duplicate» needs review

This was the module that I really needed. It has solved many issues for me. You have really helped me.

Thank you, hefox, for sharing the module, panels_tinymce.

It works great with panels version 3.2.

Once again thank you very much for sharing this module.

P.V.Anthony

#27

hefox - November 4, 2009 - 17:29

(Thank recrit, all I did was put it into appropriate files, zip+upload).

My suggestion is someone make it a module for now like imce wysiwyg bridge is a module or move over the issue to WYSIWYG issue queue.

#28

pegleglax - November 6, 2009 - 18:40
Project:Panels» Wysiwyg
Version:6.x-3.2» 6.x-2.x-dev
Component:User interface» Code
Category:task» feature request
Priority:minor» critical

It would be better to integrate it into the WYSIWYG module imo.

Moving it over :)

 
 

Drupal is a registered trademark of Dries Buytaert.