3

On a site I am developing, I have installed and enabled CKEditor version 7.x-1.13.

On two of the pages, I need to completely disable the editor from being active when accessing the admin to edit the page.

I am not sure how I can do that. The only thing I have been able to do is either enable or disable the editor globally.

Can someone point out to me how I can get this done?

2 Answers 2

0

AFAIK, you can only control access to the wysywyg editor on a per-user basis, not on a per-node basis. If the user shall be allowed to use the wysywyg editor in general (but be banned from doing it only on specific pages, you need to create write PHP-code that prevents the user selecting the wysywyg text format on the pages were this shall not be allowed).

What you can control on a per page/node basis is the default editor.

To not make the wysywyg default for an existing page, open up the page as Admin, locate the box labeled "Text format" below the main edit area, and select a format (e.g. "Plain text" *) that has not been set up to use wysywyg.

Save the node. Wysywyg will no longer be default when it is reopend for editing (but it can be selected).

However: If that user has global access to at least one text format tied to wysywyg, he or she can restore the wysywyg for that page at will.

To stop the user from doing this, you must prevent the user from changing the text format. You can do this by using hook_form_alter() to remove the pull-down menu that changes the text format for the node edit form.


*) If you want something more advanced than "Plain text", and the "Filtered HTML" (for instance) format has been assigned to wysywyg, just clone the text format you want to use, but do not set it up to use wysywyg.

0

You can solve this problem by preventing CKEditor module from loading CKEditor based on your conditions.

The condition can be anything, permission, page URL or arguments etc....

CKEditor load by adding pre render callback for text format element using hook_element_info_alter.

You just need to do is to take that callback off.

here is example code for disabling the CKEditor module in any page has 'add' as 2nd argument.

function example_element_info_alter(&$types) {
  if (arg(1) == 'add') {
    $key = array_search('ckeditor_pre_render_text_format', $types['text_format']['#pre_render']);
    if ($key !== FALSE) {
      unset($types['text_format']['#pre_render'][$key]);
    }
  }
}

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.