Implement the following:

  1. The filter's configuration screen should allow you to set Help, Config. and Spec. once for that input format.
  2. If you want to have different configs for htmLawed in different situations, then you need to make different input formats.
  3. If someone wants different formats for node bodies, comments, blocks they can use a contrib module (I use better formats). This also allows you to choose input formats per content type.
  4. Views already allows you to choose your input format for headers and footers.

See #987946: disappearing image for more details.

CommentFileSizeAuthor
#1 1095752-htmLawed_one_config-1-D6.patch54.41 KBandyf

Comments

andyf’s picture

StatusFileSize
new54.41 KB

Here's how I would personally modify the module. I haven't included anything about upgrading yet: I'm not sure what the best approach would be. Here's one idea.

  1. The default body config, spec and help settings for each input format are copied into the new variables, and they'll be the settings used.
  2. The old settings (htmLawed_format_x) aren't automatically deleted.
  3. A separate module can be enabled that lets you view your old settings to make it easier to copy them to new input formats. This process is not automatic (I can't think of a sensible way it could be).
  4. When you've completed the migration and no longer need the old settings, there's an option to delete them.

What do you think?

andyf’s picture

Status: Active » Needs review
alpha2zee’s picture

AndyF, thank you for suggesting this patch. I haven't had the time to test it as yet, but I will do so soon. I will like to point out two things though.

Regarding one htmLawed setting per input format:

(1) The current htmLawed module has a 'default' setting for 'Config', etc., which is by default used with all content-types. Content-type-specific settings are set by disabling use of the 'default' setting and providing content-type-specific values for 'Config', etc. Thus, one does have an option to have just one htmLawed setting for an input format.

(2) It is possible to use the Better Formats module with htmLawed regardless of whether there is just the 'default' setting in use and no content-type-specific setting, or there are content-type-specific settings in effect.

Regarding the 'Body' vs. 'Other' issue, which is separate from one htmLawed setting per input format, the problem still remains. For the time-being I suggest using the same setting for both 'Body' and 'Other' by identically filling the form-fields for htmLawed configuration.

andyf’s picture

Hi alpha2zee, thanks for the reply.

one does have an option to have just one htmLawed setting for an input format.
...
Regarding the 'Body' vs. 'Other' issue, which is separate from one htmLawed setting per input format, the problem still remains

For me these are two sides to one problem. There's a particular way that Drupal's input format architecture works. At the most basic level there are filters, like this one. As I see it, a filter can be viewed as a function: it takes an input and delivers an output. Where possible (and certainly with a filter like htmLawed which might eat resources) you want to always have the same output for the same input (which makes things simpler at higher levels, and allows you to cache). It follows from that idea, that you really only want to have one set of config options (this means not having multiple content types or body-, teaser-specific settings, etc.). It really should be (imho) one set of config options per filter, period.

So what's the Drupal way of doing content type specific settings? Using input formats. This way you can create a completely customised input format for one situation, and an utterly different one for a different situation. As htmLawed stands, it works at the filter level, but offers functionality that lives at the input format level. What do I do if I want to have htmLawed and filter x to run for content type story, but htmLawed and filter y to run for content type page? I can't (not using htmLawed's content type functionality). As well as this, it's easier for a module running at a higher level to understand the context and make a correct decision about whether this textarea represents the body, a block, etc. (In fact, this was the initial problem that brought me to the issue queue - the filter was trying to decide if it should be in body or other mode, and made the wrong decision because it just doesn't have sufficient information, as it's really supposed to be a pure function.)

If you do use htmLawed with better_formats to solve the problem I describe above then you're duplicating functionality, and you have lots of settings hanging around to confuse the user (ok so although it says on this filter that it will use these settings for this content type, better formats is actually going to select an entirely different input format that has different settings). It's a recipe for confusion imho.

Also, caching can lead to unpredictable results (because the same filter yielded different results despite having same input, due to some change in context); not caching obviously has performance implications, and would certainly be a deal-breaker for me personally.

It also means that as other modules are released for interacting with input formats, there's a good chance they won't play nicely with it.

Basically, as I see it, all the functionality offered by this module is great - but it should not live in a filter. If you cut down this filter to something like my patch and use better formats you have a cleaner, less confusing, and more performant solution. I think the only thing that better formats can't do is change input format for teaser/body and for other. Maybe there's already a contrib module that does it; if not, then you can write the functionality as a separate module that isn't a filter.

Thanks for your time,

Andy

alpha2zee’s picture

I agree with your suggestion that the htmLawed module should adhere to the Drupal philosophy. The module's core function is to provide a filter. Additional functionalities that it provides are: (1) content-type-specific settings, (2) body/teaser/other-specific settings, and (3) having Drupal save filtered anand not raw content. I am not very sure that (1) and (2) deviate the module from the Drupal philosophy. Drupal 7 core takes care of (1). For Drupal 5/6 there is the Better Formats module. So it makes sense to remove (1) from htmLawed module. I don't know of a Drupal core functionality or any module for (2), but clearly there are code-logic issues which make is difficult (impossible?) to deliver (2) in a fool-proof way. So, I will go ahead and work towards releasing version 3 of the module that will not have (1) or (2).

andyf’s picture

I've just taken a quickish look, and can't find any module for (2). Maybe it would be worth seeing if the author of better_formats would accept a patch to add the functionality there?

Drupal 7 core takes care of (1)

I didn't know that, that's cool!

(3) having Drupal save filtered anand not raw content

It still seems to me that this shouldn't live in the filter. If I want to save filtered content to the database, then it would be nicer to save the output of the whole input format (not just the individual filter). And it ought to be independent of htmLawed: maybe for one content type I don't want to use htmLawed but I still want to save the filtered output to the database.

Btw, imho saving the filtered content to the db is quite a big change to the default Drupal input format system, so I think it needs lots of clear warnings!

Just my 2 cents

alpha2zee’s picture

> Drupal 7 core takes care of (1)

See http://drupal.org/node/1003262

> (3) having Drupal save filtered and not raw content ... needs lots of clear warnings!

No need to get alarmed. This is an option and not default, and the module has good documentation. For lot of Drupal administrators, HTML filtering is all that is needed, and htmLawed can be the only filter used. Saving filtered content is a handy option for those who want to use it. I will keep it in the next release.

andyf’s picture

Hi alpha2zee

I'll stop nagging you after this, but thought I might give it one last go! If I helped create a separate module that handled saving filtered content to the database, would you be ok separating that functionality from the htmLawed filter?

Thanks for your time.

alpha2zee’s picture

AndyF, I actually appreciate your 'nagging' :) Perhaps there already is a module for that #3 functionality. Let me check.

andyf’s picture

Thanks alpha2zee!

alpha2zee’s picture

Status: Needs review » Closed (fixed)

Version 3 of the module for Drupal 6 (and 7) has been released. Thank you AndyF for encouraging me to release a new version of the module. Thanks too for the patch you provided.

andyf’s picture

Thanks for all the hard work you've put in alpha2zee!

NPC’s picture

Hm, this is an odd decision, I used this module specifically to filter teasers differently from the body (so that body can have all kinds of formatting, while the teasers are shown consistently). If anyone finds a replacement module for this - could you please post it here, for completeness of the discussion?

Thanks!

alpha2zee’s picture

NPC, alongside the new version 3 of the module, version 2 of the module will be maintained for Drupal 6 and it will continue to have the old set of features.

NPC’s picture

Thanks for maintaining it, alpha2zee.