Hi,

is there a hook I can implement in a custom module to disable fckeditor on certain conditions? Usually, fckeditor should be loaded, but I have a specific condition, where I want to disable it.

The only possibility I see now is to temporarly remove a role from the user, which gives the "access fckeditor" permission. However, I'm not sure about the side effects. Another solution might be directly changing the fckeditor module function fckeditor_elements(), where it checks for user permissions. But that is for me the worst solution, because I have to manually merge this change on every module upgrade.

Any other ideas?

Comments

Jorrit’s picture

You can implement the form_alter hook and set #wysiwyg to FALSE for each textarea form element. That should work.

advseb’s picture

Mmmh, yes, this is possible, but maybe also error-prone. Not sure, if the forms all have the same structure.

I think the best solution would be to be able to enter additional PHP code in a profile. If the PHP code returns TRUE, FCKEditor should be shown. There is something similar in Drupal core for blocks.

Jorrit’s picture

Category: support » feature
Status: Active » Postponed

That's not going to be implemented in 6.x-1. It may be implemented later in 6.x-2 or -3. You can use element_children() to loop through forms dynamically (http://api.drupal.org/api/function/element_children/6)

Jorrit’s picture

Version: 6.x-1.4 » 6.x-2.x-dev
drooopalstars’s picture

Hi,

This is possible using following code.
I had a requirement where I needed to disable WYSIWYG for all my textarea fields in custom content type.
One can modify it to do for any particular field also.

//FAPI callback to process textarea field
function modulename_elements() {
return array(
'text_textarea' => array( // need to disable wysiwyg
'#process' => array('modulename_field_process'),
),
);
}

//custom function to disable wysiwyg
function modulename_field_process($element) {
$element['value']['#wysiwyg'] =false;
return $element;
}

One can refer to the below hack given in fckeditor.module for doing this (in function fckeditor_process_textarea)
//hack for module developers that want to disable FCKeditor on their textareas
if (key_exists('#wysiwyg', $element) && !$element['#wysiwyg']) {
return $element;
}

Jorrit’s picture

Status: Postponed » Closed (won't fix)

Please try CKEditor (http://drupal.org/project/ckeditor).