(Tutorial) Displaying Views' exposed filters in a block

Tutorial : Displaying Views' exposed filters in a block 

So you have Views, and you've figured out exposed filters. Which, in short, gives nice handy little widgets to search. Often by keyword or by some taxonomy term.

Now what you want to do is put that functionality in a block. Say you're doing a catalog search or you have something you just want to always be up.

No Problem!

You need 2 snippets. In Drupal 4.7, the first goes in a custom block, and looks thus:

I'm going to call the view 'catalog'. Anywhere you see that word below, you'll need to replace it with your view name. This is especially true in the theme function.

<?php
$view = views_get_view('trackerx');
$form = views_filters_form($view);
$form['#action'] = url($view->url);
return drupal_get_form("views_filters_$view->name", $form, 'views_filters');
?>

That block will display the filter form; the #action bit is to make sure the form goes to the right place. [Note: Views 1.1 will correct this so that part won't be quite as necessary.)

Now, you need to do one other thing: Make the exposed filter *not display* on the view itself, otherwise you'll get it twice. This is bad CSS at the very least, and very confusing to the user. But it's easy to get rid of.

| Read more..

Courtesy : Aangrydonuts.com