1

I want to be able to add arbitrary attributes to rendered view fields. So for example, I may want to add the attribute itemprop="url" to the rendered A tag for a url field.

I don't want to do this in the actual theming layer - I want to keep it in the view definition.

Is there a way of altering the option forms of any field handlers, so that I can add a new form element that does this. I would then need to alter the render function to ensure the field is outputted correctly with the new attributes.

So essentially I would want to change the options_form, render functions etc. in the views handler class (e.g. views_handler_field_url.inc).

Any help would be much appreciated.

1 Answer 1

2

What you need to do, is to subclass the handler(s) and add the methods you want to overwrite or change. Then you need to replace the normal handlers with your custom create handler(s) wherever you need this, in hook_views_data_alter.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.