2

I'm still not sure how hooks work.

I want to join a table to one of my views, but I have no idea where I'm supposed to put the hook for that. Do I just stick it in the template for the view? Or where does it go?

4

The API reference at http://drupalcontrib.org/api/drupal has all of the Views hook in it: http://drupalcontrib.org/api/drupal/contributions--views--docs--docs.php/group/views_hooks/6

That said, the views documentation is a little sparse. The best thing to do is look through the list of hooks, then search on the various hook names for examples.

I suspect you need to use hook_views_query_alter but I don't think I have ever had to add a JOIN to a view before.

EDIT:

Notice another of your questions: Join a custom table on a View.

In your case, if you want to properly make a custom table Views aware, implementing hook_views_data is the correct solution. But you still need to do this in a custom module, and not in your theme files.

  • Where does the hook go though? Do I have to create a new module for it, can it go in a template file? – kylex Oct 5 '11 at 18:28
  • 2
    Sorry, hooks always go in modules. – mpdonadio Oct 5 '11 at 19:03

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.