views:

67

answers:

1

I need to modify a query Views generates so that I can use highly custom filters. I have implemented the add_where() function with some ORs thanks to this question: http://stackoverflow.com/questions/1340423/or-operator-in-drupal-view-filters

However this only solves a part of my problem. There are some fields that I cannot filter on because I need to have extra JOINs in my query.

Is there something along the lines of

$view->query->add_where()

that can insert JOIN statements?

+2  A: 

Well, there is $view->query->add_table() and $view->query->add_relationship() (in the views_query class in 'includes/query.inc'), but their usage, relation and preconditions are not obvious from the code (at least not for me).

Maybe you could add the relationships via the Views UI to ensure that your needed tables get joined in.


(Note: Comment turned to answer, as no better idea showed up :/

Henrik Opel
Actually, adding another relationship in the views UI did work for me. All I had to do was look at the generated query from views to find out what table was needed to go into the add_where function. hooray!
Jukebox