8

My setup: Drupal 7.2, Panels 7.x-3.0-alpha3, Views 7.x-3.0-beta3, Chaos tool suite 7.x-1.0-beta1

Say I want to create a fruits directory website. In views I have a content pane "fruits" with exposed filters based on taxonomies "color". The website is supposed to have two panel pages. The first panel page displays only the exposed filter box "search a fruit" with a dropdowns for "color" and a search button. Upon choosing from the dropdown and clicking the search button the user is supposed to get redirected to the second panel page that includes the view's content pane displaying a list of fruits that match the filter (color).

The problem is: the exposed filter box on first page won't redirect to the result page after clicking the apply button. How do I set up views and panels to achieve this?

4 Answers 4

8
function hook_form_alter(&$form, &$form_state, $form_id) {  
  if ($form_id=='views_exposed_form') {
    global $base_url;
    $form['#action'] = $base_url.'/path_that_you_want'; 
  }
}
3
  • This works fine, but instead of using $base_url, I think you probably should use url('path_that_you_want').
    – John Fiala
    Jul 1, 2013 at 15:14
  • 1
    I tried this with no success.Actually my 'action' attribute says another destination.How can I fix this?
    – Dion
    Apr 27, 2015 at 15:34
  • Hey, where do i add this code, please let me know Thanks
    – Developer
    Jun 18, 2016 at 16:57
0

I'm not sure if there is a "right" way but I have made this happen by writing a hook_form_alter for the exposed filter form to change the destination.

Not ideal, but I got the results I needed.

1
  • How did you do this? Could you please post your code?
    – Michiel
    Nov 23, 2011 at 15:53
0

Simplest solution is to

  • Create a views page
  • Create an exposed view
  • Under Advanced > exposed form. Set "exposed form in block: Yes"
  • Add the block "Exposed form:..." to the required front page.
0

Simplest solution is to Create a views page Create an exposed view Under Advanced > exposed form. Set "exposed form in block: Yes" Add the block "Exposed form:..." to the required front page.

Interlated's above formual got me half way with exposed filter block working to open and display results on new page.

However, I also needed the filter block to be on that results page. So I attached the form (exposed filter block) via view area in the header. Then I encountered recursive behavior when both displays in same view.

To solve, I separated the two displays (page & block) into their own respective views - created one block as the exposed filter which included fields for results, then an entirely new view for page to have a URL to be reached. Page view has one field (title) that is overwritten as whitespace (mainly because results would be redundant but also inaccurate - I found results were accurately displayed from fields in exposed filter block). I kept the same filtered settings between both displays and used better exposed filters using ajax on both displays.

I did this in D8 but likely would be same on 7.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.