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
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...
#19
I've made work the WYSIWYG module for panels 2 using the code below:
<?phpforeach (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/
#20
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
amendment to previous post to handle panel pages also.
<?phpswitch($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
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
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
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
20, 21 in a module attached.
Works for me
#26
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
(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
It would be better to integrate it into the WYSIWYG module imo.
Moving it over :)