Closed (won't fix)
Project:
Views (for Drupal 7)
Version:
5.x-1.6
Component:
Documentation
Priority:
Normal
Category:
Support request
Assigned:
Unassigned
Reporter:
Created:
14 Jul 2008 at 08:11 UTC
Updated:
20 Sep 2008 at 22:44 UTC
I need to add data to e.g. a list of term ids submitted by an exposed multiselect view filter.
e.g. if the submitted term ids are 1,2 and 3, I need to add 4,5,6 and 7 to the list of term ids to filter.
Where is the best place (hook) to alter the submitted values?
Any hint really appreciated.
Comments
Comment #1
suit4 commentedfurther investigations:
currently I'm trying on views_query_alter().
$query->add_where() seems be be really close, but add_where() ads a query with an AND operator.
As I want to add values to the list, I need something like add_where() with an OR operator or
something liken $query->add_where_args().
Any idea?
Comment #2
merlinofchaos commentedYou won't be able to do that with add_where.
If you need to add terms to the filter, use hook_form_alter and alter 'views_exposed_form'. My guess is that you'd do this by adding a validate handler or extra submit handler to modify the data.
Comment #3
suit4 commentedThanks for the answer.
Is there anything to read about howto to alter views_exposed_form?
I didn't recognize it in D5 by now...
Comment #4
suit4 commentedAfter several successless tries using hook_form_alter() to inject additional values to filter for, I decided to introduce a new hook in views.module views_build_view(), which is working for me as expected and gives a clean and easy way to alter the filter values sent from exposed filters without actually breaking the query itself.
Szenario:
I need to filter content types for taxonomy term ids, which are part of a very huge taxonomy term tree structure (about 11000 terms).
I created a filter widget with a checkbox which allows the user to include all child terms of the selected terms into the filter function.
Depending on how high the selected root term is located in the taxonomy tree, there is a high number of child term ids to be inlcuded into the filter values (about 5000).
which can be called like
So maybe someone needs a similar functionality or maybe this piece of code migth be interesting for integration into the views module as well.
Any feedback very welcome.
Comment #5
sunAdding a hook is the wrong way. As merlinofchaos already pointed out, you rather want to add a validate or submit callback to the exposed filter form. See http://drupal.org/node/58689 or http://drupal.org/node/202756 for further information.
Sorry, unfortunately this support request is way too specific. Please have a look at the issue queue - Views maintainers are buried already. You might want to try to get further support at http://drupal.org/support. Additionally, the answer to your question might be covered in the handbooks at http://drupal.org/handbook/modules/views already.
If you were able to solve this issue on your own in the meantime, you might want to add the involved steps to this closed issue, so other users searching for a similar solution might find it.