7

When you expose a filter date on views you get something similar to the following:

screenshot #1

When you expose the post date you get:

screenshot #2

The former is a lot more useful. Is there a way you can get the post date to look the same?

21

Sure therefore add a date: filter not a node: post date.

On the date filter configuration form you can select the node: post date field and that's all you need.

1
  • I can't believe I missed that! – Jeff May 13 '11 at 13:15
2

To those looking to integrate this filter in a hook_views_data() definition in your own module (say, if you're trying to expose your own custom table to Views 2.x or 3.x), you need to have the Date installed, and then you can add in the following in your field definition:

'filter' => array(
    'handler' => 'date_views_filter_handler_simple', // Requires date.module.
),

The full field definition for a created date, updated date, etc. would be something like the following:

'field_created' => array(
  'title' => t('My Created Date'),
  'help' => t('When an item was created.'),
  'field' => array(
    'handler' => 'views_handler_field_date',
    'click sortable' => TRUE,
  ),
  'sort' => array(
    'handler' => 'views_handler_sort_date',
  ),
  'filter' => array(
    'handler' => 'date_views_filter_handler_simple', // Requires date.module.
  ),
),

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.