Closed (fixed)
Project:
Facet API
Version:
7.x-1.x-dev
Component:
Code
Priority:
Normal
Category:
Task
Assigned:
Unassigned
Reporter:
Created:
3 Jan 2012 at 13:32 UTC
Updated:
16 Jul 2014 at 07:42 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
cpliakas commentedI think this request makes sense, but I am not sure about the best way to approach this. Each "gap" (i.e. year, month, day, etc.) has a different format, so it would get a little verbose if we defined different date types via the hook_date_format_types() system and forced users to select which format to use on each gap. Let's discuss and see what makes sense.
Just a point of clarification, though, the dates are not actually hard coded although overriding is probably not trivial. In a custom module you can implement hook_facetapi_facet_info_alter() and change the "map callback" for date facets and implement whatever logic you need to display dates how you want them. Untested example code is posted below:
Because a viable workaround exists without having to patch the module I am marking this as a 2.x feature. In addition, It would be a great contributed module to provide a more flexible solution for the 1.x branch of Facet API.
Comment #2
cpliakas commentedPushing back to 7.x-1.x. The API should be cleaner, and can be done in a backwards compatible way. The goal isn't to provide a method to do this via the core Facet API module's GUI pages, but rather to make it easier for contrib to provide this functionality or developers to override it.
Comment #3
cpliakas commentedThe attached patch adds a bit of a cleanup. It reduces the logic needed to override the date formatting callback.
Comment #4
cpliakas commentedMarking as needs work since the "callback" option is a bit non-descriptive. It should be "format callback" for code redability.
Comment #5
cpliakas commentedMade the change. The hook_facetapi_facet_info_alter() callback would now look as follows.
Comment #6
cpliakas commentedForgot to attach patch ...
Comment #7
cpliakas commentedCommitted patch in #6 at http://drupalcode.org/project/facetapi.git/commit/180daaa.
Comment #9
freakalis commentedI had to modify your example code in #5 a bit to make it work for me.
Comment #10
jmary commentedAnother option is to use the module facetapi_bonus and the filter configuration

enable "Rewrite facet items via callback function"
and create a module with a function like in the following example :