I have overridden the default Drupal /search page with a panel view that is listing users. In this view, users can be filtered by gender, age, location, etc - and it's working quite well! I have paired Contextual Filters and exposed Filter Criteria enabled to allow GET variables to be passed to the view while still allowing for a Filter Criteria fallback. Achieving this took a few experimental patches.

Now I need to place a search form on the home page that has a few of these filter options. This form needs to direct users to the /search page and take with it whatever the user enters. I've tried using the Exposed Filters Block but doing so removes the filters from the /search page entirely and negates the view header and footer which are unfortunately essential to the view.

Creating a basic HTML GET action form that sends users to the /search page works well, but that's a nasty long URL and I would prefer to keep this within Drupal. It seems that changing this form to use POST instead of GET does not work.

Is there some way to create a stripped-down form that leads into this search view? Using the Forms API would be nice but I'm open to any other solutions presented.

1 Answer 1

  1. I would suggest writing your own form in a block which you can place on the home page. I don't see anything wrong with writing the form in HTML - though if you generate your form the Drupal way using the Form API then you'll ensure you get consistent themeing across your site, you'll be protected against XSS attacks and so on. How to use the Form API is beyond the scope of a single question ;

  2. There is a module that allows you to use POST queries with views exposed filters : http://drupal.org/project/views_expost - hopefully this should deal with your long URL problem.

  • This is perfect - I'm right at home with the Forms API. Thank you!!
    – emc
    Mar 22, 2013 at 16:59

Your Answer

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

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