Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
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.
Comment | File | Size | Author |
---|---|---|---|
#1 | apachesolr_views-date-field-handler-1932480.patch | 2.93 KB | goodydc |
Comments
Comment #1
goodydc CreditAttribution: goodydc commentedHere's the patch.
Comment #2
elstudio CreditAttribution: elstudio commentedWorks for me!
Thanks!
Comment #3
tim.plunkettIt 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.Comment #4
goodydc CreditAttribution: goodydc commentedTim,
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.
Comment #5
tim.plunkettComment #6
acidpotato CreditAttribution: acidpotato commented2 thumbs up for date module field handler!! Would love to see it incorporated in solr views
Comment #7
Gerben Zaagsma CreditAttribution: Gerben Zaagsma commentedPatch in #1 causes a missing handler error when adding a date field in the view.
Comment #8
gaele CreditAttribution: gaele commentedComment #9
helmo CreditAttribution: helmo commentedPatch works fine.
@Gerben Zaagsma: the missing handler error was probably a caching issue. It works fine after a cache clear.
Comment #11
MiroslavBanov CreditAttribution: MiroslavBanov commentedAs 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.