Closed (won't fix)
Project:
FCKeditor - WYSIWYG HTML editor
Version:
6.x-2.x-dev
Component:
Code
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Reporter:
Created:
10 Feb 2010 at 09:24 UTC
Updated:
8 Sep 2011 at 20:27 UTC
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
Comment #1
Jorrit commentedYou can implement the form_alter hook and set #wysiwyg to FALSE for each textarea form element. That should work.
Comment #2
advseb commentedMmmh, 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.
Comment #3
Jorrit commentedThat'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)Comment #4
Jorrit commentedComment #5
drooopalstars commentedHi,
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;
}
Comment #6
Jorrit commentedPlease try CKEditor (http://drupal.org/project/ckeditor).