Download & Extend

"Exposed Form in Block" views setting replaces this module for 6.x

Project:Views Filter Block
Version:5.x-1.x-dev
Component:Code
Category:feature request
Priority:normal
Assigned:Unassigned
Status:closed (fixed)

Issue Summary

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.

Comments

#1

Title:Port to 6.x?» Port to 6.x
Status:active» needs work

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.

AttachmentSize
views_filterblock_6.x-1.0.tar_.gz 7.65 KB
views_filterblock_d6.patch 6.62 KB

#2

#3

Title:Port to 6.x» "Exposed Form in Block" setting replaces this module for 6.x (was: Port to 6.x)

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

Title:"Exposed Form in Block" setting replaces this module for 6.x (was: Port to 6.x)» "Exposed Form in Block" setting replaces this module for 6.x, except for in Panels (was: Port to 6.x)

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.

AttachmentSize
views_filterblock-6.x-1.0.bugfix.tar_.gz 7.66 KB

#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.

#13

@kevin.gomes: thanks for the fixed version. I can always do a diff to see what has changed.

#14

Status:needs work» reviewed & tested by the community

@kevin.gomes: Thanks. Your fixed version worked. I'm not sure whether this module is still useful in Panels 3 now or not. I'll check, and if it is, I may apply for maintainership so we can get a 6.x branch going.

#15

Status:reviewed & tested by the community» postponed

Postponed on #808178: Make the exposed filter blocks available to panels, even though the only other views blocks are the "content panes". After that, will be a "won't fix", as per merlinofchaos in #drupal-contribute since the last piece of integration will be done.

#16

Status:postponed» reviewed & tested by the community

@momendo: the code for invoking the block didn't work because when I do module_invoke('views', 'block', 'list'), it looks like in Views 2.10, at least, the exposed filter blocks just have hashed values for names, and even when I copied that exactly, it didn't render.

#17

Status:reviewed & tested by the community» postponed

Cross-posted on myself :) So it looks like #808178: Make the exposed filter blocks available to panels, even though the only other views blocks are the "content panes" is the "correct" solution, but I have kevin.gomes' code from #11 working live for me right now.

It will be nice to finally get this closed up.

#18

Note that this module does not work in Views 3, since the views_exposed_form() code has been changed.

If you try to use it in a panel with Views 3, you will get an error similar to this one:

"Fatal error: Call to a member function exposed_form_alter() on a non-object in //sites/all/modules/views/views.module on line 1054"

The real solution to all this is #808178: Make the exposed filter blocks available to panels, even though the only other views blocks are the "content panes".

#19

Title:"Exposed Form in Block" setting replaces this module for 6.x, except for in Panels (was: Port to 6.x)» "Exposed Form in Block" views setting replaces this module for 6.x
Status:postponed» fixed

I just checked again in #808178: Make the exposed filter blocks available to panels, even though the only other views blocks are the "content panes" - the exposed form blocks are available to panels, in the Views category. But to get them to work in that context, you will need code something like #419556-19: Make 'exposed form in block' work in panels: Change the $form['#action'] of views_exposed_form to request_uri() in panels_pane.

#20

Status:fixed» closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

nobody click here