9

Does anyone know of a way to force plain text mode in comments for all roles?

Edit: is it in any way possible to do so through CSS? Thanks!

4

Take a look at admin/settings/ckeditor/editg. There you can change the visibility settings by field path (something like content_type@path.element_id). That should work.

  • 1
    What's the editg in admin/settings/ckeditor/editg ?! This takes me to the same page as admin – therobyouknow Sep 23 '13 at 14:08
6

Try

function MYMODULE_form_alter (&$form, &$form_state, $form_id)
{
  // comments
  // http://api.drupal.org/api/drupal/modules--comment--comment.module/function/comment_form/6

  if ($form['#id'] == 'comment-form') {
    $form['comment_filter']['format'] = array(); // nuke wysiwyg from comments
  }
}
  • Please excuse my ignorance but where exactly does this function go? Thanks! Jane – Jane May 17 '11 at 9:03
  • This is an example of a hook that would go inside a custom module. Though the term "custom module" may sound daunting, it is a fairly common task. The best place to start is drupal.org/developing/modules – mpdonadio May 17 '11 at 13:37
  • OK thanks! Will try, though yes it does sound quite daunting... :) – Jane May 17 '11 at 17:12
2

For Drupal 6, I would recommend the Better Formats module to control this. It allows to set a default input format on comments, but also allows different defaults per role and per content type. The Drupal 7 version is in development, but its status is a bit unclear at the moment because some of the features are now in core.

  • Yeah I have Better Formats (it's a Drupal 6 site) but either I am using it wrong or for some reason it's failing to disable ckeditor in comments... at least for the roles that have permission to use ckeditor. – Jane Jun 6 '11 at 19:41
2

I had the same problem in D7. To fix it I changed the default input format of comments to Plain Text (ckeditor did not have a profile for that input format). This removed ckeditor from comments.

To remove the input format hints I installed the better formats module.

Update: I just noticed that your question was how to force plain text mode for all roles. To simplify I would just change the way the input format process text from "filtered text" to "plain text".

0

I did it this way. I fixed input format to a non wysiwyg one and denied access of it.

/**
 * Implements hook_comment_form_alter().
 */
function comment_form_alter(&$form, &$form_state, &$form_id) {
  $form['comment_body']['#after_build'][] = 'MYMODULE_customize_comment_form';
}

/**
 * Comment body after-build function.
 */
function MYMODULE_customize_comment_form(&$form) {
  // Hide text-format selector in comment form and fix format to filtered_html
  $form[LANGUAGE_NONE][0]['format']['format']['#value'] = 'filtered_html';
  $form[LANGUAGE_NONE][0]['format']['format']['#access'] = FALSE;
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.