I know it's been labeled an improvement that you don't need to turn CKeditor on/off via text area ID, but I would really like to disable it for comments, even for authenticated users. I would like to allow users to create nodes using CKeditor but only be able to comment (or, by default be able to comment) in filtered HTML. Is this possible?

Comments

mkesicki’s picture

Status: Active » Closed (duplicate)

Hi,
I think that your issue is related to #1063986: Allow user to choose which textarea is enable by default. So I close it (as duplicate). If you need something more (not described in mentioned ticket) please reopen this issue.

flexer’s picture

I have the same issue: it seems not possible (or not easy) to disable CK from the comment textarea.

xl883c’s picture

I think the answer you are looking for is right here:
http://drupal.org/node/1157740

mattbk’s picture

I'd rather enable filtered HTML than only allow Plain Text, but this is not possible.

vlajkop’s picture

mattbk,

It is possible to disable CKeditor for comments fields, just it is a few steps process. Trick here is in setting new text format in Configuration > Content authoring > Text formats.

For my drupal 7 installation I created here new html filtered text format and name it "Filtered HTML for Comments". Important here is to put this new text format in first place in grey box that lists all text formats in bottom part of Configuration > Content authoring > Text formats. Since it is just created your installed CKEditor doesn't have profile for it. Also first place means that is going to be first selection for posting into input fields.

Now all you have to do is to set permissions for text formats. My setting is next:

  • Filtered HTML for Comments anonymous user, authenticated user, administrator
  • Full HTML administrator
  • Filtered HTML administrator
  • Plain text All roles may use this format

Filtered HTML is changed from default so it can be used only by administrator.

Downside of this is that "Filtered HTML for Comments" is going to be used as default input format for all other fields unless you remove administrator permission from this text format.

Unfortunately setting input field default under Home » Administration » Structure » Content types » Article » Comment fields just don't work in drupal 7.8.

Playing with permissions and order in Home » Administration » Configuration » Content authoring » Text formats worked for me to enable filtered html format for comments and disable CKEditor for authenticated and anonymous users.

Please note that this solution will be applied everywhere in drupal even when you creating content as administrator. You will need to switch to Full HTML to get CKEditor for text input fields unless you remove administrator from permissions from "Filtered HTML for Comments" text format.

Hope this is helpful and what you were looking for. If you find better solution please let me know.

k8’s picture

vlajkop,

The following is true also in drupal 7.9 but probably because of the setting under "Text Processing" earlier in the Comment field for the content type to be "Filtered text (user selects text format)". Yes, one would expect to be able to set the default Input filter here - separate issue - where should this be entered as an issue?

Edit the comment_body field under Comment field tab. Under "Text Processing", set it to be "Plain text" and CKEditor goes away.

From #5 comment:
Unfortunately setting input field default under Home » Administration » Structure » Content types » Article » Comment fields just don't work in drupal 7.8.

biblos’s picture

Issue summary: View changes

I find a way to disable CKEditor for defined one field without hacking module, using hook_form_alter in your module.

function YOUR_MODULE_form_alter (&$form, &$form_state, $form_id) {
  if (isset($form['FIELD_NAME'])) {
  	$form['FIELD_NAME']['und'][0]['#attributes']['id'] = 'edit-log';  	
  }
}
stevieegee’s picture

I find the $form_id to use hook_form_FORM_ID_alter(). Then you can target each content type if needed. The $form['#after_build'] removes all the information about text formats.


function MY_MODULE_form_comment_node_CONTENT_TYPE_form_alter(&$form) {

    if (!empty($form['comment_body'])) {
        $language = $form['comment_body']['#language'];
        foreach (element_children($form['comment_body'][$language]) as $key => $value) {

            $form['comment_body'][$language][$key]['#wysiwyg'] = false;
            unset($form['comment_body'][$language][$key]['#description']);
        }
    }
    $form['#after_build'][] = '_MY_MODULE__remove_ckeditor_comment_form_text_after_build';
}

function _MY_MODULE_remove_ckeditor_comment_form_text_after_build($form) {

    // Removes CK editor from the body summary field of the content type
    $language = $form['comment_body']['#language'];
    foreach (element_children($form['comment_body'][$language]) as $key => $value) {
        $form['comment_body'][$language][$key]['format']['#access'] = FALSE;
    }
    return $form;
}