Trying to create a basic view that pulls all content from the site and provide an exposed filter for the user to filter the content by the posted date.
My view is using the following settings, however the JQuery UI Datepicker does not show (manually entering the dates work).
Filter criteria
Content: Post date (exposed)
Expose this filter to visitors, to allow them to change it
Operator: Is between
Value type: A date in any machine readable format. CCYY-MM-DD HH:MM:SS is preferred.
Exposed form
Exposed form style: Better Exposed Filters
Display "Post date" exposed filter as: JQuery UI Datepicker
An export of my view. You should be able to import it as it should work on any site with content (Content agnostic).
$view = new view;
$view->name = 'archiver';
$view->description = '';
$view->tag = 'default';
$view->base_table = 'node';
$view->human_name = 'Archiver';
$view->core = 7;
$view->api_version = '3.0-alpha1';
$view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */
/* Display: Master */
$handler = $view->new_display('default', 'Master', 'default');
$handler->display->display_options['title'] = 'Archiver';
$handler->display->display_options['access']['type'] = 'perm';
$handler->display->display_options['cache']['type'] = 'none';
$handler->display->display_options['query']['type'] = 'views_query';
$handler->display->display_options['query']['options']['query_comment'] = FALSE;
$handler->display->display_options['exposed_form']['type'] = 'better_exposed_filters';
$handler->display->display_options['exposed_form']['options']['autosubmit'] = 0;
$handler->display->display_options['exposed_form']['options']['autosubmit_hide'] = 1;
$handler->display->display_options['exposed_form']['options']['bef'] = array(
'created' => array(
'bef_format' => 'bef_datepicker',
'more_options' => array(
'bef_filter_description' => '',
),
),
);
$handler->display->display_options['pager']['type'] = 'full';
$handler->display->display_options['pager']['options']['items_per_page'] = '10';
$handler->display->display_options['style_plugin'] = 'table';
/* Field: Content: Title */
$handler->display->display_options['fields']['title']['id'] = 'title';
$handler->display->display_options['fields']['title']['table'] = 'node';
$handler->display->display_options['fields']['title']['field'] = 'title';
$handler->display->display_options['fields']['title']['label'] = '';
$handler->display->display_options['fields']['title']['alter']['alter_text'] = 0;
$handler->display->display_options['fields']['title']['alter']['make_link'] = 0;
$handler->display->display_options['fields']['title']['alter']['absolute'] = 0;
$handler->display->display_options['fields']['title']['alter']['word_boundary'] = 0;
$handler->display->display_options['fields']['title']['alter']['ellipsis'] = 0;
$handler->display->display_options['fields']['title']['alter']['strip_tags'] = 0;
$handler->display->display_options['fields']['title']['alter']['trim'] = 0;
$handler->display->display_options['fields']['title']['alter']['html'] = 0;
$handler->display->display_options['fields']['title']['hide_empty'] = 0;
$handler->display->display_options['fields']['title']['empty_zero'] = 0;
$handler->display->display_options['fields']['title']['link_to_node'] = 1;
/* Sort criterion: Content: Post date */
$handler->display->display_options['sorts']['created']['id'] = 'created';
$handler->display->display_options['sorts']['created']['table'] = 'node';
$handler->display->display_options['sorts']['created']['field'] = 'created';
/* Filter criterion: Content: Published */
$handler->display->display_options['filters']['status']['id'] = 'status';
$handler->display->display_options['filters']['status']['table'] = 'node';
$handler->display->display_options['filters']['status']['field'] = 'status';
$handler->display->display_options['filters']['status']['value'] = 1;
$handler->display->display_options['filters']['status']['group'] = 0;
$handler->display->display_options['filters']['status']['expose']['operator'] = FALSE;
/* Filter criterion: Content: Post date */
$handler->display->display_options['filters']['created']['id'] = 'created';
$handler->display->display_options['filters']['created']['table'] = 'node';
$handler->display->display_options['filters']['created']['field'] = 'created';
$handler->display->display_options['filters']['created']['operator'] = 'between';
$handler->display->display_options['filters']['created']['exposed'] = TRUE;
$handler->display->display_options['filters']['created']['expose']['operator_id'] = 'created_op';
$handler->display->display_options['filters']['created']['expose']['label'] = 'Post date';
$handler->display->display_options['filters']['created']['expose']['operator'] = 'created_op';
$handler->display->display_options['filters']['created']['expose']['identifier'] = 'created';
$handler->display->display_options['filters']['created']['expose']['multiple'] = FALSE;
/* Display: Page */
$handler = $view->new_display('page', 'Page', 'page');
$handler->display->display_options['path'] = 'archiver';
Comment | File | Size | Author |
---|---|---|---|
#5 | default_drupal_date_filter-1289370-5.patch | 11.24 KB | ducktape |
Comments
Comment #1
mikeker CreditAttribution: mikeker commentedThank you for the exported view! It made it much easier to track down the problem, well... problems.
1) We were adding an ID to the input field and triggering the datepicker from that. That doesn't work with "in between" filters.
2) At some point, jquery.ui.datepicker started using a zIndex routine from jquery.ui.core that it didn't used to. So I need to include jquery.ui.core (which I probably should've been doing all along) as well as the datepicker.
Again, the exported view made this much quicker to debug (hear that everyone? :) Thank you.
I should have a fix in by later this evening or tomorrow morning depending on whether the kids need Harry Potter to be read to them or not...
Comment #2
mikeker CreditAttribution: mikeker commentedWhew... That was more than I expected it to be.
Fixed.
Note that datepickers still need to be moved into Drupal.behaviors so that they continue to operate after AJAX-based updates to the page... So datepickers are still strictly beta at the moment, but at least they'll work.
Comment #3
pixelsweatshop CreditAttribution: pixelsweatshop commentedFantastic work mikeker. You rock!
Comment #4
mikeker CreditAttribution: mikeker commentedThanks :)
Just a quick note that I cleaned up the datepicker (and (re)added the highlight code, which was somehow lost in the 6 -> 7 conversion). So datepickers should work fine with AJAX and Autosubmit.
Comment #5
ducktape CreditAttribution: ducktape commentedThis doesn't work yet for "in between" default Drupal dates (post date, updated date).
I have added a patch, which fixes this the same way as done in the above commit. I added an extra option, so the user can select a date format for this exposed filter (not everybody likes Y-m-d).
Also added a drupal_add_js to include the javascript file. I don't know why, but it wasn't there and didn't work without it.
Needs to be reviewed though, there are most likely better ways to fix the format issue.
Comment #7
mikeker CreditAttribution: mikeker commented@ducktape, a couple of good catches!
I completely forgot to duplicate the two-textfield code for Drupal's standard date fields (duh!). And I'd been doing all my testing with a Select All/None filter which meant that the BEF Javascript code was loading because of the all/none widget, not the datepicker. Again, duh!
Thanks catching those... Fixed.
I left out the date format picking. I think it's a good idea, but I want to make it consistent with the Date API widget and that may take a bit of digging. I've added #1306268: Would like to set date format in date-based exposed filters to track that.
Comment #9
vegtabill CreditAttribution: vegtabill commentedJust wanted to say thanks for the patches. BEF has been a good solution for me so far, and these patches cleared up the one issue I was having. I am in development now and will be moving to Production soon; any likelihood of an update going out in the near future? Thanks again for the patches, and the module itself, of course!
Comment #10
Toktik CreditAttribution: Toktik commentedDrupal 7 version of BEF date picker doesn't work with in-between operator.
Comment #11
hoZt CreditAttribution: hoZt commentedIs the issue of using datepicker with a range of dates an issue with views or with the BEF module? Should a new issue be opened for this?
Comment #12
adeb CreditAttribution: adeb commentedGood question, let's investigate.
Comment #13
adeb CreditAttribution: adeb commentedTurns out I forgot to select "popup" when creating the views date filter. After that, don't select jquery datepicker in the BEF settings, but use default input. It works for me.