There is tons of documentation about adding field handlers to specific fields, but for me it only works when handling specific fields.
In my case I want to add an advanced rendering (=rewrite results in UI) option that can apply to any field, similar the trim and ellipsis options in views_handler_field.inc.
Unfortunately I've been unable to get views to recognise my extensions of the views_handler or views_handler_field class. I've tried the following in mymodule.views.inc:
class mymodule_handler_field extends views_handler_field {
function option_definition() {
etc.
class mymodule_handler_field extends views_handler {
function option_definition() {
etc.
Neither get picked up. In the meanwhile the other field definitions in mymodule.views.inc work fine. Is there some special naming convention I need to use for my class extension, and/or in the hook_views_data implementation.
Comments
Comment #1
merlinofchaos commentedYou must be misunderstanding how object oriented programming works.
Simply extending a class isn't going to automatically replace all existing calls to that original base class with your class. That simply isn't going to work, and it can't work.
There isn't a way to do what you're suggesting. It is an artifact of using inheritance. This is probably why you can't find any documentation on doing it: you can't.
Comment #2
jurriaanroelofs commentedWell, since I have a use case for doing it I'll turn this into a feature request then.
I have an abbreviation function that I would like to be able to apply to any text field. Any suggestions on how to implement this?
Comment #3
merlinofchaos commentedYou don't understand.
You can't do it. Sorry, but that is one of the artifacts of the design of the system. You can't do this.
Comment #4
merlinofchaos commentedThe closest thing you can do is that you can identify fields you want to modify, use hook_views_data_alter() and change the 'handler' for each field to your new one.
Comment #5
jurriaanroelofs commentedok, thanks for your time.