If you build a View with an exposed filter you may want to put this filter in a block. This is can be done to separate filter from view results and to display exposed filter in any part of your website.
To do this, go and edit your view.
But what if you want to theme this block and change the way exposed filter behaves, what do you do?
Since there is no any mention of “exposed filter in a block template file” in Views Theming information list, it is a bit tricky to guess which file to edit and how to name it. Here is what you should do:
- Go to Views installation folder (sites/all/modules/views) and look in ‘theme’ folder. There you will find ‘views-exposed-form.tpl.php’ file.
- Copy this file to your current theme directory, in my case it is sites/all/themes/timonweb
- Now, check your views name, in my case, it is ‘user-comments’.
- Rename your newly copied file by following this formula: views-exposed-form--view-name.tpl.php (NOTE “--”). In my case file’s name is: views-exposed-form--user-comments.tpl.php
- Clear your theme cache by flushing it with admin_menu module, or by going to your View and clicking “Rescan Template Files” under Style settings -> Theme Information.
That’s it, now you can edit views-exposed-form--user-comments.tpl.php file and all changes will be shown in a block with your exposed filter.