The current version of the module uses its base field handler for date fields. Doing so treats date fields as strings, which limits output options. I have written a simple date field handler that extends the views_handler_field_date class, thus providing the same options for formatting date output as that class.

Essentially, the handler overrides the get_value() method to convert the date string returned by apachesolr to a Unix timestamp. Options for formatting the output are inherited from the views_handler_field_date class.

Please review. Any feedback/improvements are welcome.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

goodydc’s picture

elstudio’s picture

Works for me!

Thanks!

tim.plunkett’s picture

+++ b/apachesolr_views.views.incundefined
@@ -57,9 +57,11 @@ function apachesolr_views_views_data() {
         case 'tdate':
           $filter_handler = 'apachesolr_views_handler_filter_date';
+          $field_handler = 'apachesolr_views_handler_field_date';
           break;

It would be great to utilize Date module field handlers if possible. The date_views submodule has a better handler, and field would need to have 'is date' => TRUE in the definition.

goodydc’s picture

Tim,

Thanks for the suggestion. I thought about that as well. I opted not to utilize the Date module initially because I did not want to add a dependency to Apache Solr Views. I'll revisit that idea, and see what I can do.

tim.plunkett’s picture

if (module_exists('date_views')) {
  // use the good one
}
else {
  // use the bad one
}
acidpotato’s picture

2 thumbs up for date module field handler!! Would love to see it incorporated in solr views

Gerben Zaagsma’s picture

Patch in #1 causes a missing handler error when adding a date field in the view.

gaele’s picture

Issue summary: View changes
Status: Needs review » Needs work
helmo’s picture

Patch works fine.

@Gerben Zaagsma: the missing handler error was probably a caching issue. It works fine after a cache clear.

MiroslavBanov’s picture

Status: Needs work » Fixed

As far as I can see there is no field handler in date_views module - there are filter and argument handlers. Maybe I am missing something, but I couldn't see one.

Applied the patch that adds the date field handler, so this is now fixed.

Status: Fixed » Closed (fixed)

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