Drupal 7 Views Exposed Filters in Blocks (and panels)

By shane
Sun, 2012-04-22 19:42
12 comments

Ran into a views and panels issue today that was very simple to fix, but difficult to track down. Here is my situation in case you run into a similar views/panels issue.

I have one Drupal 7 panel page that does a lot of visibility rule filtering based on the path of the panel. Depending on the path, I have different pieces of content that show up. In some situations, this may be a view (othertimes it is static content, custom coded blocks, etc).

I wanted some of my views that are displayed in the this panel to have an exposed filter to allow easy searching. As I normally would with a view, I simply turned on the exposed filter on the views admin interface and went to make sure it was working... no luck. No exposed filter was being displayed.

I began searching for a solution and it turns out to be very simple. I have my views set up as block displays. In order for exposed filters to work with block views, you need to have Ajax enabled in the view. All I had to do to get this working, was go to the views admin and switch "use AJAX" over to "YES". After that, my exposed filters began showing up in my panel page.

A few things to note. This isn't really an issue with panels, it is only related to views being displayed as blocks, however in my situation, panels is what led me to encounter the problem. Any views block will need AJAX set to YES in order to see the exposed filters.

I also know that it is possible to set up Views Content Panes to use in my panels pages, instead of using Views Blocks. However a year or so ago, back in Drupal 6 I ran into a lot of restrictions with how Views Content Panes handled arguments and panels context, so I stopped using them. I have not used them recently so I can't say if those issues have been fixed or not yet. If anyone has arguments or opinions on why using Views Content Panes are better than using Views Blocks for displaying inside a Panel, I would be happy to hear you out.

Happy Drupaling.

5 Secrets to Becoming a Drupal 7 Ninja

Comments

Just ran into this issue, and fixed it from this post. I'm like, where is my exposed filter?!

Thanks Shane!

Thanx, but what if I dont want the exposed form to load the result on the block, but on the page ? Is that possilble ?

Works great, but what if I wanted to display the exposed filter as a block, so i can manipulate its location. I know this is possible when the view is a page (Exposed Form Option), but this option isn't available when displaying the view as a block. Any workarounds?

One field in my view is a fulltext search, which I have exposed as a block and placed in the sidebar. The problem is that it doesn't redirect to the pane, it just sticks the parameters in the current URL. I was able to work around this by creating a page display in views with the same URL, and then disabling it. This makes the exposed filter block point to this page, but since it's disabled, the content pane takes over. Is it possible to do it without doing this, or is it a bug?

I have learned a lot from you and your videos. I was pleasantly supervised to see a link from you related to my issue. Not only did you fix it but you found the simplicity that others were making so complicated.

SHANE YOU ROCK!

Thanks for all of your time.

Post new comment