0

I want to pass the value from one view to another view's filter I have view 'filter' which is having the select box with taxonomy list as option 'category_taxonomy' having fruits,vegetables. I want to pass the taxonomy value to next view in on change event to filter the value in view 2.My both 'view1' and 'view2' are in same tpl.If I select the value from view1 I wat to send the argument to the second view and and filter the result and then reload only the second view(view2).

$vocabulary = taxonomy_vocabulary_machine_name_load('service_line');
$terms = entity_load('taxonomy_term', FALSE, array('vid' => $vocabulary->vid));
// print_r($terms);
echo '<select class="filter"><option value="">select</option>';
foreach($terms as $data){
  echo '<option value='.$data -> name.'>'. $data -> name.'</option>';
 } 
echo '</select>';
4
  • Please clarify the expected flow here. When user clicks on that filter in View 1, you want to redirect the user to View 2 and remember the selection they made in View 1? Or do you want View 1 to process the filter selected and show filtered results but remember filter selection in case they go to View 2? Jan 20 '17 at 4:58
  • please check my updated post Jan 20 '17 at 5:03
  • So the taxonomy filter isn't really a filter - it acts more like a jumpmenu to View2 with the taxonomy value, correct? Jan 20 '17 at 5:07
  • yes u are absolutely correct Jan 20 '17 at 5:13
0

One way to do it is to create a jumpmenu in your view's template and add it to the page that way instead of trying to do it with filters.

So in your view's Advanced tab, click on "theming" option, and a dialog box will open with your view's template name. Copy the views.tpl from the views module to your theme and name it that template name. Inside this template you can now find the place you want to output this jumpmenu and add the tax_terms code you have above. Only instead of outputting the options as a form field, convert them to links using JS here's one example. Or you can also create the jumpmenu as ctools like here.

5
  • I want to have the first view as it is and reload only the second view Jan 20 '17 at 5:35
  • in your comments above you said you want to navigate from first view to second view, this is exactly what this does Jan 20 '17 at 5:43
  • do you have both views as blocks showing at the same time on one page? Jan 20 '17 at 6:05
  • yes showing at same time in custom tpl for content type Jan 20 '17 at 6:09
  • ah, then maybe this post could help. Jan 20 '17 at 6:42

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.