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 |
Jump to:
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
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
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
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
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
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
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
is there a solution to this for D6/panels2 then?
#8
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
Any solution for WYSWYG module in D6/Panels 2?????
#10
Hey the solution I posted is for drupal 6 + Panels2 + tinymce. Do you want to know some thing else?
#11
Hey the solution I posted is for drupal 6 + Panels2 + tinymce. Do you want to know some thing else?
#12
Sorry guys , I noticed that my I posted the same post twice.
#13
<?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
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
I suggest to consolidate separate TinyMCE / FCKeditor solutions into a single one based on WYSIWYG API module, intended as their replacement.
#16
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
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
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...