Right now, computed fields do not allow other formatters to apply on node views. This is bad. Other formatters could be useful. I've implemented a custom formatter for a client site that originally worked only number fields, but I expanded it to work on computed fields. I was disappointed to see that computed field prevents this behavior.
Attached is a patch that removes the offending code, allowing for any formatter to apply. If users want the display hidden, they can set it in the content type display settings.
This opens computed fields to more opportunities for neat display. (Plus, you can already apply formatters to computed fields in views, let's make node behavior consistent).
Cheers,
-Mark
| Comment | File | Size | Author |
|---|---|---|---|
| computed_field_respect_formatters.patch | 865 bytes | mfredrickson |
Comments
Comment #1
karens commentedThis patch would also fix problems noted at http://drupal.org/node/202384 and http://drupal.org/node/243775, that the 'view' value isn't available to contentemplate or token module.
Comment #2
mooffie commentedThis patch is identical to the one I already suggested at that other issue.
To which Sergey replied: "without 'view' it is impossible to calculate field on every node view due to caching."
I'm marking this a 'duplicate' of that other issue (for lack of any other option; unfortunately, we don't have a 'depends on / blocks' feature as in bugzilla).
Let's discuss Sergey's concern there. I wrote up a little summary.
Comment #3
sin commented>Attached is a patch that removes the offending code, allowing for any formatter to apply.
Formatters are a separate issue. CF has special PHP field for formatting so it may need no additional CCK formatters by design. mfredrickson, to reuse your formatter code you can call your custom formatter from CF PHP formatting code. Unfortunately I can't provide an example. Please post one if you managed to do so.
Comment #4
markrei commentedhi there, im new to drupal could anyone please help me on how to make this patch working? i mean where should i put this code?
Thanks in advance
Comment #5
deekayen commentedNobody ever made a DRUPAL-5 branch for this module, so I'm going through closing 5.x patches. If it still applies to 6.x, re-open as appropriate.