I believe I have developed a fix for excluding Fckeditor from specific textareas. The problem originally was that Fckeditor would only check for element['#id'], which would usually appear as simply "edit-body" or somesuch in the form.
To resolve this so that we can exclude specific textareas precisely, I've modified the function fckeditor_process_textarea() to add "-$nid" (the $node->nid or node id #) to the end of the results of element['#id']. This also gives administrators the ability to exclude fckeditor from entire nodes.
This code can (and should) be further refined to exclude entire site sections such as "admin," "user," etc. This would probably be accomplished by tying it to paths instead of node id's. I'll work to add this instead and post the updated code here--any help / suggestions appreciated.
I'd also like to know how to create a patch (I'm on a Windows platform) to make it easier for everyone to apply. Any help with that would be appreciated. I'm usually on one of the #drupal IRC channels as "JoshuaL". Thanks to dfletcher and chx for providing coding help and direction.
/**
* This function create the HTML objects required for the FCKeditor
*
* @param $element
* A fully populated form elment to add the editor to
* @return
* The same $element with extra FCKeditor markup and initialization
*/
function fckeditor_process_textarea($element) {
/** Added to include '-$nid' to $element['#id'] so fckeditor can properly
catch specific textareas. Will change id of both textarea and textarea label. */
if (arg(0)=='node' && arg(2)=='edit') $nid = arg(1);
$element['#id'] = $element['#id'] . '-' . $nid;
$exclude = preg_split("/[\s,]+/", strip_tags(variable_get("fckeditor_exclude", '')));
| Comment | File | Size | Author |
|---|---|---|---|
| #2 | fckeditor.patch | 685 bytes | JoshLangner |
Comments
Comment #1
JoshLangner commentedComment #2
JoshLangner commentedHere's my first patch ever. Suggestions / recommendations would be helpful!
Comment #3
ontwerpwerk commentedI like the idea, and it might be usefull in real life situations too, so I'll see if I can include it as soon as I fix the next problem...
Which is that the interface for enabling or disabling that textarea is so far away... all over in administer >> settings >> fckeditor
Comment #4
JoshLangner commentedWhat approach are you taking for that? My thought would be to add a checkbox to enable / disable the editor directly on the edit-node page under the textarea. Could even tie in some JS to make it dynamically appear / disappear. A global textarea exclusion (in fckeditor >> settings) should override the appearance of the checkbox option for specified nodes (nid), sections (admin/*), textarea id's, or textarea types (i.e. 5 lines or less). I think this would easily tie in to the code I submitted above.
Comment #5
JoshLangner commentedI've updated my patch code to append the URL of the page to the textarea and textarea label ID's, so that you can disallow per page and per textarea. This makes wildcard excludes more fun. Here are some examples:
You just need to paste the following code at the top of the fckeditor_process_textarea function in fckeditor.module.
It could probably still use some tweaks. Help is always welcome.
Comment #6
ontwerpwerk commentedwouldn't
be better?
Comment #7
JoshLangner commentedYes, this would be a slightly faster method. I added a '-' to the front of $fckpageurl in the second line, since using $_GET['q'] does not start with the beginning slash like requesturi() did. Here's the updated code:
Comment #8
lias commentedThank you, thank you Joshua Langner , this works great on my install of 5.0. I was having the worst time trying to get adsense to work in a block but now all is good.
Comment #9
ontwerpwerk commentedan option to work with paths is in the current development release
Comment #10
(not verified) commented