Hello,

I was searching the forum and also googleing for this but didn't found any. Take my excuse if there's already a similar topic.

Shortly said: I want to get rid of the "Filtered HTML" input format for specific content-types.

The long story: Given two content-types, say "Story" and "Other Type" and two input formats, say "Filtered HTML" and "Other Input". "Filtered HTML" is set to be default.

Now, unfortunately, "Filtered HTML" doesn't apply to "Other Type" in any way, hence it
a) Appears as possible format when editing "Other Type" and - worse -
b) Is the default input format.

Is there a possibility to work around this? Either by
a) Assign a fixed input format ("Other Input") to content type "Other Type" (other than hardcoding a node's format ID, which I already did) or
b) Assign different formats to different user roles, without having one format rule them all, like it is currently. That is: Without the default format beeing assigned to all roles.

Comments

robertdouglass’s picture

Since the filters are only role based, and not content based, you'll need to make two roles, each having the the right to make one of the two content types, and configure the content types for those roles accordingly. I don't see any other way.

- Robert Douglass

-----
My sites: HornRoller.com, RobsHouse.net

gerd riesselmann’s picture

I was thinking and trying in this direction, also. Indeed, I created two roles (say A and B): one may edit only Stories, the other only "Other Type". All users are either assigned Role A or Role B, none is assigned both roles.

However, since "Filtered HTML" is set as default (and one input format must be default), it automatically is assigned to each and every role. Which definitly is not want I want :-(.

------------------
Gerd Riesselmann
www.gerd-riesselmann.net

robertdouglass’s picture

You're right. I don't see an easy way around having to hack the code a bit.

- Robert Douglass

-----
My sites: HornRoller.com, RobsHouse.net

gerd riesselmann’s picture

Thanks for your replies, nevertheless :-)

I started to hack and think I'm finished now. Just had to change three lines, actually.

Just for the records, here they are:

  • In function filter_admin_overview() around line 293 change
    //old: 
    $row[] = form_checkbox('', "roles][$id][$rid", 1, $default || $checked, NULL, $default ? array('disabled' => 'disabled') : NULL);
    //new:
    $row[] = form_checkbox('', "roles][$id][$rid", 1, $checked, NULL, NULL);
  • In function filter_formats() around line 573 change
    //old:
    $query .= ' WHERE '. implode(' OR ', $where) . ' OR format = %d';
    $args[] = variable_get('filter_default_format', 1);
    //new (second line was removed):
    $query .= ' WHERE '. implode(' OR ', $where);
  • In function filter_form() around line 760 change
    //old:
    $tips = _filter_tips(variable_get('filter_default_format', 1), false);
    //new:
    $tips = _filter_tips($format->format, false);

All this happens in file filter.module.

A note: This hack applies in my special case, where there is excatly one input format per content type.

------------------
Gerd Riesselmann
www.gerd-riesselmann.net

Compactman’s picture

I need this kind of control as well.

u4umar’s picture

The easiest solution for this problem is the Better Formats module.
http://drupal.org/project/better_formats
This module gives you the full controll to make default input format at node, comment and block level along with role level.
Here is drupal site at which I have used it.
http://www.pepads.com

NickHBO’s picture

I have this same issue, but the code has changed since the hack was posted.

Basically, the problem that I am having is caused by my use of two TinyMCE profiles (though this issue applies to many situations where a contributed module doesn't even come into play). I am using TinyMCE's more advanced HTML features for users of a certain role, while anonymous and authenticated users get a stripped down version of TinyMCE that adheres to "Filtered HTML". Obviously, I have to make the lower one the default because I don't want anonymous and authenticated users to have the ability to use "Full HTML".

This becomes a workflow issue because if the user with the higher role forgets to change from filtered to full HTML, he's going to lose formatting detail and worst of all may not even notice it initially. Added to that is the fact that the option is now collapsed on the cluttered node submission page and the reason this is an annoyance becomes apparent.

I'll give a full rundown of how I think this problem can be addressed in a way that makes Drupal more flexible, but to be honest I'll take any hack that'll let me specify an input format for a special role case directly in code.

Addressing the Problem (without a hack)

The reason a system "default" filter must be selected is obvious, Drupal's filtering should work out of the box and it's easy to overlook ticking a box when you're initially creating your site and setting up roles - the "default" feature is definitely an important one. However, I think with a few changes to how it behaves, it can be much more flexible for situations like the one I outlined above. The problem boils down to automatically selecting a default input format (IF) for a role when a role is assigned to multiple IFs. We could take the approach of removing the checkbox disable code for the default IF so we could deselect roles, then force the first IF with that roll checked to act as the default. However, that's undesirable because you may not want the IF it selects to be the default and there may be security implications as well.

To solve this problem, I propose the introduction of a second "default" setting. To the left of each role in each IF would exist a second checkbox, "role default", that would allow the admin to set the current IF to being that role's default. This second checkbox would show up next to all roles in all IFs except those in the system default IF and the "anonymous user" role in all IFs. There's no need to have the second checkbox next to roles in the system default IF because if they are checked then the system default IF is implicitly the role's default IF. The "anonymous user" role should lack this checkbox in all IFs to ensure that the admin realizes he is setting the IF that will always be applied to a visitor that is not authenticated. Since "anonymous user" is the lowest role an admin will configure - as it applies to every visitor to the site - all other roles should default back to the IF you would allow anyone to use; being unable to change the "anonymous user" default IF from the system default IF helps to illustrate this.

The roles in the system default IF should remain disabled at all times, as they currently do. If an admin changes a role's default to another IF, the checkbox for that role should be unchecked but still disabled in the system default IF. Next to the unchecked role, a link labeled "revert" would allow the admin to set the role's default back to the system default IF. The revert link only appears in the system default IF and only when a role's default has been switched to some other IF. It may be nice to have a Javascript popup explain the revert action and confirm that the admin wants to do it, but this is not necessary. If the revert confirmation functionality is to be added, it should have an option to disable the check on the main Input Format settings page.

When in an IF that is not the selected system default, the "role default" box will appear next to every role except "anonymous user" (for reasons explained above). When the admin checks off a box and saves changes, the module should check to see if any other IF that is not the system default IF is already serving as the role's default IF. If it is found that the role already has a default IF (that is not the system default IF), the admin would be informed what the IF was and asked to confirm that they wanted to change it. If the admin confirms or if no other IF is acting as the role's default, the module sets the selection to be the role's default. The check and subsequent prompt should have a setting on the main Input Format settings page to disable it if the admin wishes; by default this option should not be selected so the checks automatically occur.

If a "role default" box is unchecked and the page is submitted (indicating the admin no longer wants that IF to be the role's default), the system default IF should automatically switch back to being the role's default IF and the checkbox should show up as checked the next time the admin views the system default IF configuration page. On the main Input Format settings page, all IFs that are not the system default IF should list "(role default)" next to each role that it is the default for. For example, instead of the "Roles" listing for "Full HTML" showing up as "anonymous user, authenticated user, custom role", it would read "anonymous user, authenticated user (role default), custom role (role default)" if both "authenticated user" and "custom role" had set it as their role default IF.

The last case that requires special handling, that I can think of at this time, is changing system default IF. When changing from an old system default IF to a new one, it should not take over and become the default IF for all roles; instead it should transfer over what roles currently use the system default IF as the role default IF and leave the rest be. It's less likely that somebody will want to reconfigure all the formats than it is that they will want to reconfigure one or two. For the cases where they do want to reset them all, the system default IF configuration page should have a "revert all" option that will make all roles default to the system default IF; for this action, confirmation is required and cannot be disabled via a setting.

I've tried to cover all possible situations, but I may have miss one or two; if so I'd be happy to brainstorm solutions to any issues you may find with the above proposal. I think the UI setup I've laid out is sufficient and pretty easy; though the UI could be made simpler, it would require more recoding of the module than the benefit would be worth. I don't know how hard these changes would be to make, but for whomever may do them, I think it would be a great fix for the filter module and make Drupal just that much more flexible.

Please let me know what you think of the above proposition.

Nick

chrisd’s picture

Hi Nick,

I agree on principal. Did not read your entire post too long (sorry got other urgent tasks to complete tonight...).

But to summarize what I think (and maybe you wrote...):

1) What ?
"We need to be able to select a default Input_Format (IF) for each role."

2) Where ?
"The UI for this, could be located on Input_Formats."
The only issue is if someone "checks" (checkmark UI widget) different default IF for the same role (need some validation and/or warning ?).
The other option (better in my opinion) is to add the a selection list on the role_screen to pick the default IF for the role. More elegant but as of today "role" screens have never had any options. Could be a nice first.... ;-)

Thx,
Christophe D.

PS: Nick could you add this as a feature request on the roles or filter module and keep us posted in this thread. Keep it short remember the Drupal Developer are volunteers...Thanks!

Tech. articles with a WAMP+IIS+Drupal focus

Take a break: Guide to France

Chris Star’s picture

I followed this thread which began with assigning default input formats by CONTENT - TYPE, and alas, all the effort has gone into assigning IF to users by role.

I'm trying for something ike this: Assigning, say, full html to "stories" and filtered html to "forums".

Sometimes choice is NOT a good thing.

Any suggestions?

koorneef’s picture

I've the same problem with wiki nodes (in my case books) and other nodes with should have their own default input formats.

After searching I only found the ugly hack to modify the book_form() function in book.module:

// $form['body_filter']['format'] = filter_form($node->format);
  $form['body_filter']['format'] = filter_form(7);

The number 7 is the number of my PEAR wiki filter input format (find that out by inspecting the links in the input format overview admin page).

It works, I'm happy, but it is not elegant, and I would really like to find out if there is another way. When I update to a newer version of Drupal or re-arrange my filters I've to manually edit the file again ...

Maybe a custom module that overrides the _form() hooks ? Anybody any suggestions ?

harriska2’s picture

subscribe and will try out koorneef's hack. Would love this in drupal 6, especially with all the various input types now available (with the PEAR wiki gives many).

beauregard’s picture

I am using cck and tinymce in my drupal site. I want to have different default input formats for different content types. Or, also possible, the possibility to define a default input format for the user defined fields in cck.

Grammarian’s picture

I want to enable limited tiny MCE for only certain fields of two content types. Each content type is associated with specific roles, so I will have to work around it that way. But it seems like an obvious thing to be able to do.

Jean Gazis

9802008’s picture

Here is a way to change the default input format per role:

in filter.module replace this line in function filter_form() (around line 800):

<?php
 $value = filter_resolve_format($value);
?>

with this:

<?php
global $user;
	if (is_array($user->roles) && in_array ('Admin', $user->roles)) {
		$value = 5;
	}else {
  		$value = filter_resolve_format($value);
	}
?>

In the above example I have a role called 'Admin'. Any user who has role 'Admin' will have input formt number 5 selected as the input format. Hover your mouse over 'configure' on this page to see what the number is for your filter: ?q=admin/filters

www.johnstonwebsolutions.com/we_install_modify_and_maintain_drupal_web_s...

ianchan’s picture

filtered HTMl input format and a Liquid Wiki input format. On pages that are using the category container of "Wiki" or have the input format set to Liquid Wiki, I would like to disable TinyMCE.

I've using the "Show if the following PHP code returns TRUE (PHP-mode, experts only)." option to display TinyMCE. What would I use to determine if a node's input format?

Head of Library Technology Initiatives and Development
California State University San Marcos
http://biblio.csusm.edu/

liquidcms’s picture

thought it was there.. but i guess not..

hard to believe we can't set input format for specific node type

sounds like a new module

Peter Lindstrom
LiquidCMS - Content Management Solution Experts

bradtem’s picture

This has gotten more frustrating now that in 5.0 the input filter is a hidden choice you have to reveal to change.

On my site, I want the anonymous users to default to filtered html. In fact, that's the only format they can get. However for me, the owner of the site, I never want to use filtered html, I want to use more advanced formats -- normally marksmarty, but occasionally some others. Right now I have to manually switch every time and manually switching has gotten harder.

Mostly I don't want anon users and ordinary users to get advanced formats unless they are explicitly looking for them because mostly they would make mistakes. This is particularly bad for anon commenters because they can't edit after the fact if they goof it up.

So a per role defauilt would be great, but a per-user default might also be just fine.

notarealperson’s picture

I echo these sentiments exactly.

+1

MatthijsG’s picture

Using Scribefire, the posts will be uploaded as filtered html but Scribefire uses Full HTML!

======
There are 10 people who can count binary
They who can and they who don't

wilmegape’s picture

This is a big issue for me. It is now impossible to post an article via scribefire, as the api uses the default filter being filtered html. I want it to be full html. Going to drupal eacht time after posting it via scribefire defeats the purpose. Changing the default to full is also not an option as this default also applies to comments.

MatthijsG’s picture

-- triple post

======
There are 10 people who can count binary
They who can and they who don't

rkn-dupe’s picture

subscribe

shawn.sh’s picture

I also would like to see a solution on this matter

pushkar’s picture

Watch the Filter default module http://drupal.org/project/filter_default

look at the support requests - http://drupal.org/node/109019 looks like something similar

Quint’s picture

I poked around in my Drupal admin menus for quite a while, then decided to come look for some help. I'm disappointed this is not possible. I'm concerned mostly because I seem to have gathered from the posts that full HTML is a security risk, but getting my trusted authors to click "full HTML" is just one more thing they forget to do. They can't even remember to choose a menu, so I had to take that out and use the Views module. It needs to be just "title" and "body", and submit.

So, is it true there's no way in 5.1 to restrict anonymous users to filtered HTML (or just basic text), without making the trusted roles have to click Full HTML (which they can't remember to do)? (The module mentioned is only 4.7.)

How much of a security risk is Anonymous Full HTML? Or do I have that wrong, and it's not a risk? Can a nasty anonymous user enter PHP in as full HTML? I can think of irritating things they can do, and nothing really dangerous, but I certainly don't know all the tricks.

Quint

fellowlinguist’s picture

It's been a long time people have been asking for this... I think its pretty reasonable to have node types with different default input formats. (esp. since I have wiki pages and html pages). So, I dunno. I think it's needed.

Tony Radcliffe

physiotek’s picture

i think it's needed too.

+1

jochenh’s picture

this is pretty important and needed...

+ 1
-------
http://quilted.org

meerkat’s picture

I spent quite some time hunting for the ability to configure the filter (or disable TinyMCE) for specific content types only to find, according to this thread, that it's not possible.

Saying that, if anyone's got any suggestions...

adrien.gibrat’s picture

take a look to http://drupal.org/project/filterbynodetype

Sounds like what everybody is looking for here

meerkat’s picture

Thanks!

syquest’s picture

It's not a solution for my 4.7 sites!

This module is exclusive to Drupal 5.1. Could someone please place a patch or better yet a ful module developed for 4.7. That would be very supportive.

physiotek’s picture

2007-Jun-18
i have been fast on that one!!

SimonEast’s picture

Yes, I really needed that too. Just installed it, gonna give it a shot.

Simon.

hobbesVT’s picture

nice module for a first solution, but:

- leaves the "Allowed HTML tags:

... More information about formatting options" text there - just the bullets are gone ... (on my 5.3 installation with TinyMCE as well) ... maybe I could try this display:none thing ... not sure if I"ll go there ...

- does also not work on nodes where you have several input fields ... only applies for the first one

Over all - a core solution would be nice ... :-)
This issue has been out there long enough - imho

alex-and-r’s picture

The same problem with "only applies for the first one". If we have different content-types and they are not similar to story or page then we have this module not working. There's already an issue report http://drupal.org/node/179536 but I suppose no actions were made to get rid of this bug.
My be anybody here can help?

mrgoltra’s picture

subscribing.

rimma’s picture

I have tried the Filter Default module. It does not work. the default input format you only can choose Filter Html for all roles. (or maybe too many bugs). Waiting for a better solution for this issue.

Richard Ma
www.meetcampus.com

physiotek’s picture

well i dont know what is filter default module but it seems that filterbynodetype is working fine for me..

Artem’s picture

Subscribing. Setting default input type per role is important for me. Full HTML is needed for editors, Filtered HTML for anonymous and regular users

kirie’s picture

Subscribing. This would be a valuable addition.

sander_123’s picture

How can i change the input filter on all (+/- 2000) nodes of a specific content type that are already in the database?

http://horntabs.net

tech4him’s picture

First I presume you meant Input Format and not filter.

That being the case, you could do something like this in your DB, obviously changing the format type to match your desired input format and the content type to match your desired content type.

Try in Test environment first!!!

UPDATE main_node_revisions m inner join main_node n ON m.nid=n.nid AND m.vid=n.vid
SET format=4
WHERE type='wiki';

primalmedia’s picture

It seems to me like it should be really strait forward.

Full HTML for Authenticated & no HTML for Anonymous

bartezz’s picture

subscribing

________________
Live fast die young

elliotttt’s picture

Recently came across the same issue, has anyone figured out a good solution to this?

netentropy’s picture

This appears to be a widely needed module.

I need different filters applied to node body, a custom cck field and comments.

Filters should be based on role and user type

rinvelt’s picture

subscribing

TheSchaef’s picture

With a CMS that thrives on different content types as part of its flexibility and power, default input format per content type seems like a no-brainer. Someone please add, module or hack this.

gracearoha’s picture

subscribing

geoffmallo’s picture

subscribing

Bobuido’s picture

Anyone care to review / document their experience with this?
http://drupal.org/project/filterbynodetype

I was originally using a Link CCK field but I was getting a lot of errors thrown on the Live Server (I think because the MySQL is quite old). I had to drop all my link fields as a result. Now I'm using a text field but it would be great if the users didn't have to select Full HTML each time...

Current (Main) Project: http://www.wii-view.co.uk

1kenthomas’s picture

I think the solution is the default filters module.

Tmanagement’s picture

default filters module is not a solution since it focusses on roles instead of node types. I will try the filter by node type module but it seems that the module is not that alive anymore looking at the last release date.

1kenthomas’s picture

It does both, sure, it has a role-first, node-type-second interface, but it will do what is requested here.

mrgavindb’s picture

Has been working well for me, but have not done enough testing to be for certain that filterbynodetype is a great solution.

Christof’s picture

Any solution for Drupal6?

jcwatson11’s picture

It appears that a generous user has contributed a patch to the drupal 5 module that brings it up to speed for drupal 6. See http://drupal.org/node/221424#comment-878940

You also need to read the following posts in that thread. Another user caught an error that needed to be fixed. The error correction was not addressed in the patch published under the link above.

citronica’s picture

Apparently this will be part of core in D7, but until then there's a very useful D6 module called Better Formats (http://drupal.org/project/better_formats). Completely solved the problem for me.

Note that it didn't work right until I followed the instructions at http://drupal.org/node/360451 about changing the role weights at /admin/settings/filters/defaults.