By tng@neuralgourmet.com on
I'm sure I'm being an idiot here, but how would I disable tinymce from loading in the text area for trackbacks?
I'm sure I'm being an idiot here, but how would I disable tinymce from loading in the text area for trackbacks?
Comments
options
Interesting problem, you are looking for a means to disable Tinymce by referral or something? Couldn't tell you how to do that... options that I can offer, turn Tinymce off for the anonymous role. Or the solution that I use is to have Tinymce off by default and set it to show a link to enable rich text, I think that solution rocks.
------------------------------------------------------------------------------------------
"You can always find the storm by listening for the Thunder."
function
Thanks. That looks like exactly what I want.
Which file is that in? I looked in tinymce.module and the javascript files in modules/tinymce/tinymce/jscripts/tinymce and did not find it. Or should I add that function to tinymce.module? What function should I call it from?
There really should be a way to control the loading of TinyMCE on a per textarea basis in the Drupal tinymce settings.
I see TinyMCE has a way of controlling display based on a block of PHP code returning true. Could we control whether or not TinyMCE displays on a per textarea basis from there?
Neural Gourmet | Feed Your Brain
Carnival of the Liberals -- Thinking Liberally
That function is in tinymce.module 4.6.0
It's in my tinymce.module :-)
Just insert this code at the start of the function and edit to whatever text areas you do/don't want.
But see comments below re using a theme-based approach
cheers
Rob
I'd like to be able to control TinyMCE on a per-textarea basis
My site is primarily a group blog so I use the trackback module. The problem is that the TinyMCE settings only control whether or not it displays on a page-level basis. But I want TinyMCE to show for the body and excerpt textareas, but not the trackback textarea. Hopefully I'm making sense.
Neural Gourmet | Feed Your Brain
Carnival of the Liberals -- Thinking Liberally
Yeah, let us know when you develop it
I'd be interested in looking at your solution to this tng, when you develop it please let us know.
----------------------------------------------------------------------------------
"You can always find the storm by listening for the Thunder."
OK, got it sorted.
This turns out to be really easy but the documentation is not very clear.
The documentation says about function theme_tinymce_theme:
That's not the case though. There is no need to add this function to your template file, it already exists in tinymce.module. All that's required to disable loading of TinyMCE for the trackback text area is to add one extra line to the first set of case tests in theme_tinymce_theme, like this:
If someone knows of a better way of doing this, please let me know.
Neural Gourmet | Feed Your Brain
Carnival of the Liberals -- Thinking Liberally
Oh cool
I missed these posts when i wrote previous reply, and back when i wrote the above hack i didn't understand theming :-)
the whole point of the theme_... functions is so you don't hack tinymce.module.
So don't change theme_tinymce_theme at all.
Say you are using a them called fred. In YOUR fred.theme module, you put a function fred_tinymce_theme and THAT function will automatically replace theme_tinymce_theme. So you put your textarea override code in function fred_tinymce_theme in fred.theme, not in theme_tinymce_theme in tinymce.module.
The upside is that there are no changes in the base tinymce.module, just in fred.theme that you change anyway. the drawback of the theme-based approach is that you have to set it for each theme and if you add a new theme you may forget. in some ways I prefer the hack in the base module.
Oh, very cool. Thank you.
So, for Neural Gourmet where I'm using the adc theme right now I just need to put that function in my adc.theme module and call it adc_tinymce_theme instead of theme_tinymce_theme and it will override the TinyMCE settings. That's very slick. Still, it would really be nice if we had this capability in the admin/settings/tinymce. Thanks so much for the clarification. I really appreciate it.
Neural Gourmet | Feed Your Brain
Carnival of the Liberals -- Thinking Liberally
that's the theory
...haven't had time to try it yet, nor will i for weeks the way things are going. let us know how you get on
Yes I agree.. Rather do it
Yes I agree..
Rather do it on the theme level:
I added the following to my template.php file:
note that this was done to disable tinymce on comment fields (and not trackbacks)
Same concept though
Forgot the return statement
Return added for completeness. Won't work without it.
case 'log': // book and
case 'log': // book and page logRight.. now how do I figure this one out... I added a new block with PHP code (where I obviously do not want to load TinyMCE)
How do I know the name of the textarea? ...like "Log" in the above example...
I did a "view page source" on the page and I see:
<textarea cols="60" rows="15" name="edit[body]"Is that the name I use?
Like:
case 'edit[body]': // disable for custom block code????
Thanks
Associate an editor with a filter
others will correct me if I am wrong: I think the main body text is always called that, PHP or not. The way i know to deal with PHP is to associate the editor with a filter. Then the editor is sincluded for some input formats but not for those which also include the PHP evaluator (or any opther formats where you don't want it). I haven't done it for TinyMCE (yet) but here's how I did it for FCKEditor (this is 4.6 code):
name="relatedlinks_fieldset[relatedlinks]"
In reply to jacauc:
I had the same issue after I installed the relatedlinks module. The textarea to manually define links comes up in page source as name="relatedlinks_fieldset[relatedlinks]".
I eventually found that what works is:
case 'relatedlinks-fieldset-relatedlinks': //related links
Not sure why.
Instructions Wrong?
So the instructions in the module's install.txt are wrong?
"Once TinyMCE is enabled, the default behavior is that all textareas will use TinyMCE for all users. The admin can change these defaults at administer > settings > tinymce"
I can't seem to find those defaults in the TinyMCE profiles.
this code works for me great...
tried to hide tinyMCE from
tried to hide tinyMCE from trackback-field in drupal 5.2 - and it seems to need a '-' instead of '_' as a separator..
instead of
..dont know about the other fields yet, the trackback-field was the one I wanted to disable first..
greetz, t..
___________________________
my pictures: www.bilderbook.org
___________________________
This could be due to
This could be due to Pathauto replacing all underscores with dashes.
Ok, but can you hide the "enable rich-text" link as well?
I've been able to avoid tinymce loading on my "terms and conditions" text box in the user profile using the technique explained on this page. The terms and conditions text box thus loads as a protected text area (users can't change the terms and conditions). Tinymce is not on for this field, but there is an "enable rich-text" link. If the user clicks it, tinymce is then loaded for the text area, and my terms and conditions becomes unprotected again!
Is there anyway to avoid users being able to turn on tinymce using this link?
Thanks!
STeve
Steve
Revista Y AHORA QUÉ | Selectividad - Universidades - Foro Blog Chat Estudiantes
any chance there is a way to
frorget it i got it thanks
Even easier
View HTML source from TinyMCE and remove the "< p >" and "< / p >" tags from the text. Then it works.
disabling tinymce for cck fields
I just spent an hour or so struggling to figure out the proper naming convention for cck text fields. Thanks to some superb help from a friend, I finally found it.
Here's a sample piece of code to disable a cck textarea field:
Just pop that in to the the theme_tinymce function, and away you go!
need advise
hi, i try to solve the tinymce problem for my website. i have cck field name "field_description".
based on your example, i create this
then i paste it in my template.php along with the snippet above
the tinymce still on for that text area. please advise if i have make any mistake
thanks
for Drupal 5.1 + CCK
use
(despite original id of textarea in page source)
thank you
thank you for the help. i manage to disable tinymce for the textarea.
I cant get this to work with 6.2
I cant get this working with 6.2, did this change? The name looks the same.
Thanks
Enable for 'body' textarea only?
I'd prefer to work the other way around, only enable TinyMCE for certain fields. Is that possible?
Oops...
Sorry I appear to have switched my brain off momentarily there. For those interested...
Cannot disable / enable
Hi Guys
I just spent several hours in trying to disable or enable TinyMCE for particular text areas. I'm for example using the module "Related Links" and wanna disable the editor there. Unfortunately, i did not succeed. I've read the README.txt provided with the TinyMCE module and pasting the phptemplate_tinymce_theme() function from the README file into my template.php does not do anything.
I even tried the method described above:
but this does not do anything... Any help?
Regards,
Peter.
More info?
Not sure I can be much help but might help to know more information about your set up. Are you using Drupal 5? Which version of the module etc?
More information
- latest version of drupal (5.1)
- latest version of both the TinyMCE module and TinyMCE itself.
Bullet proof way of finding the field name
This was bugging me for ages but I figured how to find the field name. First enable TinyMCE and make sure the controls are showing in the field you don't want them to show. Then go to view source. At the top you should see some script like this:
The last part we're interested in is
Now simply remove the 'edit-' at the beginning and that is your field name! So in your template.php it would like like
Hope this helps some people,
Neil
- Connecting Language Learners
www.huitalk.com
--
Neil Cameron
Just add the following
Just add the following statement temporarily:
It will list all the names of the textareas!
-----------------------------------------
Joep
CompuBase, Drupal websites and design
And if I want just "simple"
And if I want just "simple" theme for creating pages (node/add/page)?..
What I have to add here?
Disable TinyMCE based on node-type
We had the requirement to not only disable TinyMCE based on field names, but also to disable it for certain node-types. Since I was using a function in template.php to disable based on field-names (as per the instructions), I just added some logic to it. In this case I'm whitelisting node types - you could just as easily blacklist instead.
Hey! Thanks for the code,
Hey! Thanks for the code, although I do not quite understand how !in_array() works and why it was a little different from http://drupal.org/node/134425
But just so anyone wants to accomplish what you did, there is no need to add that code in a template file. Just enter it into the Visibilty field of a TinyMCE profile and set it to "Show if the following PHP code returns TRUE (PHP-mode, experts only)." Then enter the following code:
This is all really confusing
This is all really confusing to me. And this is the last step for site completion and I didn't see it coming.
When generating a node, my users have the option to post a custom signature as opposed to the one in their profile.
The TinyMCE editor show for the CCK field "signature"
however when it is displayed it doesn't formate it shows all the html tags.
I dont know how to fix it.
I want my users to be able to use the editor on their signatures but the code to not show
And to blacklist certain pages (like webforms), do the reverse
I wanted to keep tinymce from showing up in the editing pages for webforms, but still have it show up for all other types, including comments. Here's a slight variation of the code above (with some help from http://drupal.org/node/64135#comment-271177), to go in the "Show if the following PHP code returns TRUE (PHP-mode, experts only)" area of the tinymce settings for a given profile.
:(
<? phpinfo();?>
alert("spam");:(
Perfect. This is exactly how
Perfect. This is exactly how I was able to remove tinymce from fighting with custom content types!
Thanks
Derrick
subscribing
subscribing
I don't know why this
I don't know why this happens but when I request a page for webform module i.e. node/add/webform or node/nid/edit (when that node is a webform) I get a white screen with "disable rich-text" twice.
My fix was to use theme_tinymce_theme and add in some logic of my own:
I used these settings in TinyMCE visibility (show on only these pages):
Replace node/add/content-type with a list of your own custom content types. The reason I use these visibility settings is because node/add/webform caused the white screen.