"Exposed Form in Block" setting replaces this module for 6.x, except for in Panels (was: Port to 6.x)
EvanDonovan - April 21, 2009 - 15:31
| Project: | Views Filter Block |
| Version: | 5.x-1.x-dev |
| Component: | Code |
| Category: | feature request |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | needs work |
Description
Any plans for a port to 6.x and Views 2? I need this functionality for my site, so I am going to try to make a port if no one else is working on it.

#1
Attached is a very basic port of the Views Filter Block module to 6.x, both as a .tar.gz and as a .patch file. I am indebted to http://www.computerminds.co.uk/displaying-exposed-filter-form-views-drup... for explaining how to create a views filter block in Drupal 6. This module just automates the process a little bit.
Note that I do not have a theming function or a form_alter in here, so you will get the filter block just as it is generated by views. If you want to override the theming for the views filter block, you should copy views-exposed-form.tpl.php from the views/theme directory to your theme directory and clear the theming cache.
As for the form_alter, which is used to make sure that the block doesn't show up twice, I don't know how to code it for Drupal 6. Maybe someone else can help with this. It wasn't necessary for my site's implementation, since we use views filter block to display the exposed filters on a separate page from the view itself.
#2
This maybe useful to some:
http://civicactions.com/blog/2009/apr/28/views_filter_blocks_drupal_6
#3
Wish I had known that "Exposed Form in Block" was an option under the Basic Settings in Views 2. Then I wouldn't have gone to the trouble of working on this views filter block port.
So then I guess the question becomes: is there any need for this module for 6.x? Should it become simply a tpl.php for the exposed filter block?
#4
It's not all roses. There's still some odd integration issues. For example, Views2 with Panels2 alpha3, you can't add an exposed filter block into a panel page. You have to use PHP to insert the block. Panels3 is still in flux and not ready for production.
Like:
$view = module_invoke('views', 'block', 'view', '-exp-research_articles-page_1');$block->content = $view['content'];
As far as coding views templates, preprocess forms can achieve the same effect:
function MYTHEME_preprocess_views_exposed_form(&$vars, $hook) {
// only alter the jobs search exposed filter form
if ($vars['form']['#id'] == 'views-exposed-form-jobs-search-page-1') {
// Change the text on the submit button
$vars['form']['submit']['#value'] = t('Search');
// Rebuild the rendered version (submit button, rest remains unchanged)
unset($vars['form']['submit']['#printed']);
$vars['button'] = drupal_render($vars['form']['submit']);
}
}
#5
Thanks for the preprocess code, momendo. That looks like a good solution. I was just using a views-exposed-form.tpl.php in my theme directory, but that would affect all the exposed forms.
After posting yesterday, I saw that it doesn't work with Panels2. I tried upgrading my site from Panels2->Panels3 last week but the database upgrade didn't work for me. I'm hoping that the code for the upgrade will be improved soon.
#6
subscribing
#7
Ok, so it looks like the Exposed Filter setting in Views 2 is not working with Panels for 6.x yet, so Views doesn't have a full solution.
So this is code is still useful to some, although I will probably not be working on it anymore (its current state is fine for my purposes). I would like to know if anyone gets the code in #1 to work successfully in Panels 3, however. I can't see why it wouldn't work, but it would good to know for sure.
#8
I get this when I install on panels 3 and using views2 on the latest version of drupal 6
* warning: Invalid argument supplied for foreach() in /drupal/includes/menu.inc on line 258.
* warning: array_merge() [function.array-merge]: Argument #1 is not an array in /drupal/includes/menu.inc on line 323.
* warning: Missing argument 1 for drupal_get_form() in/drupal/includes/form.inc on line 69.
* warning: call_user_func_array() [function.call-user-func-array]: First argument is expected to be a valid callback, '' was given in /drupal/includes/form.inc on line 366.
#9
That seems to be a problem with how the module interacts with Drupal's Form API. My suspicion is that Chaos Tools (the backend of Panels 3) is messing with something, but, since I don't have a Panels 3 setup, I can't confirm that.
#10
The same problem
http://localhost/drupal6.13/?q=admin/settings/views_filterblock
# warning: Invalid argument supplied for foreach() in C:\webserver\Apache2.2\htdocs\drupal6.13\includes\menu.inc on line 258.
# warning: array_merge() [function.array-merge]: Argument #1 is not an array in C:\webserver\Apache2.2\htdocs\drupal6.13\includes\menu.inc on line 323.
# warning: Missing argument 1 for drupal_get_form() in C:\webserver\Apache2.2\htdocs\drupal6.13\includes\form.inc on line 69.
# warning: call_user_func_array() [function.call-user-func-array]: First argument is expected to be a valid callback, '' was given in C:\webserver\Apache2.2\htdocs\drupal6.13\includes\form.inc on line 366.
#11
There was a bug on the Views Filter Block settings page. This PHP error is mentioned at many places.
Uploading a A Bug fixed version for download. You can specify the number of block this module should generate.
#12
Can you specify what the difference in code is between this and the version I posted in #1? I'd like to know where the error was coming from. Thanks.