I have a View that contains many blocks. I want to customize the query for a specific block.
I have tried views_query_alter() hook and $view->query->add_where, but in this case the query will be modified for all blocks.

Any idea of how to customize the query using add_where for a specific block?


You can check $view->current_display in your hook_views_query_alter to alter the query differently for each different block.

| improve this answer | |
  • 1
    I have fixed the problem by checking $view->build_info['title'] ... thanks – Alaa Mar 21 '12 at 11:14

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.