I've made a start on handling date arguments and allowting them to work with the apachesolr date facets.
I've attached a patch with my changes from the latest dev release (24th November).
A couple of notes:
At the moment, I have introduced a dependency on the date_api module. Using this saved me a lot of time in handling a nicer date format than the ApacheSolr ones - e.g. 2009-11 - instead of the full ISO from/to range.
I wanted the urls to be tidy when using the date facets drill down. Since this often involves multiple arguments separated by commas, the patch attempts to merge these where possible - e.g. view/2009,2009-11,2009-11-25 simply becomes view/2009-11-25. The code works, but perhaps isn't yet as elegant as it could be.
Comment | File | Size | Author |
---|---|---|---|
#10 | 642430-10.patch | 10.31 KB | mvc |
#5 | apachesolr_views-642430.patch | 6.41 KB | kenorb |
#4 | apachesolr_views_date_argument_updated.patch | 14.15 KB | Hadrien KOHL |
apachesolr_views_date_argument.patch | 9.27 KB | smoothify | |
Comments
Comment #1
smoothify CreditAttribution: smoothify commentedComment #2
Maikel CreditAttribution: Maikel commentedI applied above patch against the 6.x-1.x-dev version. And am using Apachesolr Search Integration (6.x-2.x-dev) with the following patch (http://drupal.org/node/558160#comment-2755896) applied, that patch makes adding cck date fields possible.
So i added a view, set the date argument (created date) and the block is showing up but it does not work. I see the links, but they link to nothing.
If it is of any help, using the block without a view does work.
What can i be doing wrong? More feedback needed?
ps: Would this patch be a good starting point to add the same functionality for cck date fields/facets?
Comment #3
Anonymous (not verified) CreditAttribution: Anonymous commentedsubscribe
Comment #4
Hadrien KOHL CreditAttribution: Hadrien KOHL commentedHi all,
I adapted the code to work on latest dev version.
Cheers,
Comment #5
kenorb CreditAttribution: kenorb commentedUpdated against last CVS HEAD version.
I didn't test it yet.
Comment #6
kenorb CreditAttribution: kenorb commentedComment #7
kenorb CreditAttribution: kenorb commentedThis patch should be converted into non date_api dependent. And proper if's.
Comment #8
smoothify CreditAttribution: smoothify commentedI will be revisiting this myself soon, as I need this functionality on a site that has been delayed since my first post here.
I agree that we should try and remove the dependency for date_api. My hope when creating the patch was that we could decide exactly what format the date arguments and make sure the direction is clear - but since then I haven't used Solr Views much.
Looking at the patch it seems the main function in use from date_api is arg_range(). So, it should be pretty easy to replicate that functionality into the handler, even if its almost a direct copy.
Comment #9
Equinger CreditAttribution: Equinger commentedThe patch in #5 cannot be used on the latest dev version. The last "Hunk" does not match up.
Comment #10
mvcpatch #5 didn't work for me because 'created' and 'changed' weren't included in the list in apachesolr_views_query::part_of_facet_block(), meaning that get_path() didn't call argument_part() to generate the facet links. patch attached against version 6.x-1.x-dev from datestamp 1265932882 (11 Feb 2010). i'm not planning to upgrade my production sites to newer versions of this module unless and until there's a stable release to use, but hopefully this patch will still be applicable to later versions.
i didn't consider replacing the call to arg_range() because that function is nontrivial. date handling in general is complex and i think using date_api here is perfectly reasonable.
Comment #11
kenorb CreditAttribution: kenorb commentedComment #12
rjbrown99 CreditAttribution: rjbrown99 commentedYou could always leave the dependency, and just roll this into a sub-module that is enabled independently of the main apachesolr_views module. Just an idea to compartmentalize the dependency.
Comment #13
smoothify CreditAttribution: smoothify commented@rjbrown99
I agree with that moving into a submodule would makes sense here, if that route is taken though, something would need to be done about the argument_part function - we would need some kind of hook in there so we could manipulate the argument.
Comment #14
kenorb CreditAttribution: kenorb commented