0

I've got this module which makes an additional field available when you base the view on Users. The field is made available through hook_views_data().

I've created a filter for this field, and it should be exposed to users. However, what I would really like to do is to create a custom filter. That is, a very custom form with some specialised options which the user can choose between.

How do I go about doing this? How do I tell Views that I've got this custom exposed filter. I know hook_views_plugins has something to do with this, but I can't find any place which describes the general picture of how things interact. Does anyone have any experience with this; and how things work together and which pieces I need to solve the "puzzle"?

Any input appreciated!

0

I guess the best place to start is to look at the way some other module is doing it. Or how views itself does it for some core module :) (i.e. taxonomy or user. There is at least 3 things you have to do :

  1. tell views you have something for it
  2. provide it :)
  3. tell drupal to load it

the telling can be done by implementing :

  • hook_views_data in case you define an entire field, or
  • hook_field_views_data_views_data_alter (no doc if i get it right) if you want to change someone elses field filtering

create a directory views, place a file called your_module.views.inc in it and put the hooks there.

then create a file with a class that will extend the filter

and include that file in the modules info file

dont forget to refresh cache and that should be it :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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