Using a fresh test site, I've created a very simple Event content type (just title, date and body) and configured VGF to filter views by the date field, which is just dd/mm/yyyy.

As showned in the attachments, the node form is all right but the filter form (placed on Highlight region) displays the field duplicated.

The only configuration different from the default I've made was marking Invoke widget immediately upon select.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

3magnus’s picture

As I see it now, it's suposed to be a date range (although I didn't wanted that) and there is a major bug with CTools autosubmiting textfields.

Anyway, eliminating the autosubmit option doesn't make VGF work with Date fields (but for a normal view filter it does) and the following errors keep being displayed:

  • Warning: date_timezone_set() expects parameter 1 to be DateTime, boolean given in format_date() (line 2006 of /home/magnus/Publico/entaoonde/includes/common.inc).
  • Warning: date_format() expects parameter 1 to be DateTime, boolean given in format_date() (line 2016 of /home/public/mysite/includes/common.inc).
  • Warning: date_timezone_set() expects parameter 1 to be DateTime, boolean given in format_date() (line 2006 of /home/public/mysite/includes/common.inc).
  • Warning: date_format() expects parameter 1 to be DateTime, boolean given in format_date() (line 2016 of /home/public/mysite/includes/common.inc).

If someone could show me a working configuration of a global filter for a Date field (just date, without time) I would appreciate it very much.

RdeBoer’s picture

Assigned: Unassigned » RdeBoer

As explained in the Views Global Filter documentation, a date field will ALWAYS display as a range (from start date to end date) . It would be very limiting if you could only filter by a single date!
Auto-submit was developed for the simple widgets -- it may not work for all inherited widgets, like Dates.

As for the Warnings, I will look into them. Suspect you have a very recent version of PHP?

The README of the module has a special section on Dates (copied below). Did you follow it?

On my system I have just tested on 7.x-1.x-dev a date field on a custom content type. It's Global filter works with the 3 available widgets (triple-select, popup calendar and text field) and all three work with or without the "Invoke widget immediately upon select" box ticked.

For the text field the default format on my system is "20 Dec 2012"

GLOBAL FILTER FOR DATE OR DATE RANGE
==========================
If your content does not already have a date field attached, add one as per
normal via the Manage Fields tab on the content type page. You may pick any of
three Date types, i.e. plain, ISO or Unix Timestamp. Just be aware of this bug
in the Date module: drupal.org/project/node/1477180. So until this is fixed,
maybe avoid Unix Timestamp. When prompted pick any of the available date
selection widgets, e.g popup calendar or the triple select list. You may tick
the "Collect an End date" box too, if you wish. After you have configured on
the block configuration page a global filter for the selected date field or
range, the global filter will render itself using the same widget you picked for
the field on the content type. However, the global filter will always appear as
a date range. Filtering on a single date would be a little restrictive!
Finally, as with any other global filter you need to hook it into your view as
a contextual filter. Use either just the field start date or create a second
contextual filter to also require the content's end date being inside the
filter range. In either case scroll down the bottom of the contextual filter
panel to the heading "Dates to compare". Press the button "Only this field".

RdeBoer’s picture

Title: Duplicated Date filter » Global date filter issues
FileSize
104.11 KB

Attached a snapshot of a working example of a View driven by a single Global Filter block containing three field filters, all with "Invoke widget immediately upon select" (aka auto-submit) ticked. That's why there is no "Set" button. If one, two or three of the widgets were NOT auto-submit there would be a Set button for those, but still allowing the other widgets to auto-submit as well.

The Date filter in this example is a plain Date field (not a Date ISO or Date Unix field, although these work too) and the widget is a popup-calendar (although triple-select and text field work fine too, with or without auto-submit).

The location drop-down is a plain select (not inherited) and the price category is the "options_buttons" widget, which is inherited from the original field.

Global Filter block with 3 auto-submit filters and corresponding View results

RdeBoer’s picture

@3magnus:

Are you filtering by a FIELD (one whose names starts with field_...) or a "Content property" like "Content: Created date (CCYYMMDD)"

RdeBoer’s picture

Status: Active » Closed (cannot reproduce)

Closing due to inactivity and the fact I cannot reproduce this.

iaminawe’s picture

Hi,

I just wanted to ask a question relating to whether its a field or a content created date.

With a field it seems to work correctly for me and I get date pickers I can use to set the date range and my content is filtered.

In another instance I need to use the content post date and the most relevant field I can see to use would be Content: Created date (CCYYMMDD) but using this I cant seem to get it to work properly and I cannot seem to get the date pickers or dropdowns, only a text field.

Thanks
Gregg

RdeBoer’s picture

Title: Global date filter issues » Global date filter issues: implement start and end date textfields
Version: 7.x-1.9 » 7.x-1.11
Category: bug » feature
Status: Closed (cannot reproduce) » Active

Hi Gregg,
Yes because Created (Posted) date is a node property, rather than a field, it does not have a widget attached and so the widget that will come up is a simple text box.

What I've just realised is that in thw case of dates the module only presents one textfield i.e. for an exact match. For dates, this should be 2 boxes, so that start and end dates can be entered.

Changing to feature request.

Rik

iaminawe’s picture

Thanks Rik, unfortunate to find that out now - I have 350000 nodes that are going to need a re-import to map the date to a date field.

Thanks for the clarification though and for an awesome module
Gregg

RdeBoer’s picture

How long can you wait? I may be able to do something this weekend. Rik

iaminawe’s picture

Doing a fresh import will take over week of cron running every 3 mins and importing 300 feeds items - I would be happy to wait until Monday before starting to batch import everything again.

If I need to re-import everything its only time it will take to update the new date fields so it will be a background process for a week and up until then the only thing that wont work correctly is the global date range which I can live without for a week or two.

It would be amazing if you could implement it to work with the core date field but no pressure - enjoy your weekend.

RdeBoer’s picture

Priority: Major » Normal

@iaminawe, #10:

Ok, some relief... but we're not quite there yet.

As mentioned, the "Created" and "Updated" node properties are architecturally different from Date fields.
"Created" and "Updated" date ranges are not supported by core, but are supported via the Views Contextual Range Filter module (using the latest 7.x-1.x-dev snapshot of 28 July or later).

When used in combination with Views Global Filter, the date range UI widget comes up as a pair of TEXT boxes -- not pop-up calendars, yet.
This may or may not be good enough for you, considering that without further widgetry the format to be used in text fields for start and end dates is dictated by Views, i.e.
YYYYMMDD, e.g., 20130729 or year-only, year + month, month-only, week only or day only.

That's how far I got...

Rik

iaminawe’s picture

Thanks so much for the progress and possible workaround - I will take a look at the views contextual range filter and the combination to use for the short term but will likely re-import anyway to map the dates to field to use the available widgets.

Thanks so much for the assistance, much appreciated.

RdeBoer’s picture

Status: Active » Fixed

"Created" and "Updated" date ranges are supported as text boxes. The Views Contextual Range Filter module is required for this type of date.

I'm postponing the implementation of Date-module style calendar picker for the node creation and node updated date properties as a feature request.
I simply don't have the time right now.
Patches welcome.

Rik

Status: Fixed » Closed (fixed)

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

joao.delgado’s picture

FileSize
33.6 KB

global filter by date reverses the day and month as the picture shows

RdeBoer’s picture

Title: Global date filter issues: implement start and end date textfields » Global date filter issues: implement start and end date textfields for node creation and modification dates
Status: Closed (fixed) » Active

@jhmdmgae, #15

I am not so sure about your assertion. Input formats and output formats may be different.

Note: this issue was about the node creation and modification dates... Is that what you're doing (in combination with the Views Contextual Filter Range module)? Or are your textfields for Date fields (as opposed to date properties?)

Rik

RdeBoer’s picture

Status: Active » Closed (fixed)
stevecory’s picture

Issue summary: View changes

I'm needing help with Drupal 7.36 Global Field using a Date field with a Pop-up Calendar Widget.
It has no default date set in the Content type.

I'm setting:
Views, Contextual Filter, When the filter value is NOT in the URL, Provide default value,
Type = Global filter (field or search term) and Dates to compare= Only this field
all other settings are unchecked.

Which results in:
Notice: Undefined index: #title in theme_date_combo() (line 375 of /var/www/html//sites/all/modules/contrib/date/date.theme).

Here's a portion of sites/all/modules/contrib/date/date.theme
. . .
/**
* Returns HTML for a start/end date combination on form.
*/
function theme_date_combo($variables) {
$element = $variables['element'];
$field = field_info_field($element['#field_name']);
$instance = field_info_instance($element['#entity_type'], $element['#field_name'], $element['#bundle']);

// Group start/end items together in fieldset.
$fieldset = array(
'#title' => field_filter_xss(t($element['#title'])) . ' ' . ($element['#delta'] > 0 ? intval($element['#delta'] + 1) : ''), /* LINE 375 */
'#value' => '',
'#description' => !empty($element['#fieldset_description']) ? $element['#fieldset_description'] : '',
'#attributes' => array(),
'#children' => $element['#children'],
);
// Add marker to required date fields.
if ($element['#required']) {
$fieldset['#title'] .= " " . theme('form_required_marker');
}
return theme('fieldset', array('element' => $fieldset));
}
. . . and I need to know what I'm missing.

Thank you for your help.

RdeBoer’s picture

Status: Closed (fixed) » Active

Reopening from closed (so it won't go unnoticed).

Thank you, Steve, for your report.
I don't have a solution right now, but I hope to get back to you.

Rik