Closed (outdated)
Project:
Apache Solr Views
Version:
6.x-1.x-dev
Component:
Code
Priority:
Normal
Category:
Support request
Assigned:
Unassigned
Reporter:
Created:
22 Jul 2010 at 09:16 UTC
Updated:
13 Nov 2018 at 15:55 UTC
Jump to comment: Most recent
Comments
Comment #1
toemaz commentedYou could use hook_apachesolr_modify_query(). See also #632962: Using hook_apachesolr_modify_query()
Comment #2
Maikel commentedthanks for your quick reply!
Would this be a total filter, or a configureable filter within Apachecsolr Views? I was also looking at creating a filter handler for this module, could that be a possible solution too?
Thanks again.
Comment #3
toemaz commentedThe above snippet is to alter the query. It's not a configurable filter.
For creating a configurable filter, you need to implement 2 hooks
hook_views_handlers()
hook_views_data()
and most likely implement a handler which extends one of the views_handler_filter subclasses.
There is no date filter for apachesolr_views yet, so I would put this now under a feature request. So, try to look at how Scott has made the other filter handlers and try perhaps to extend the views_handler_filter_date class.
Comment #4
Maikel commentedAllright,
I have implemented:
hook_views_handlers()
hook_views_data()
By hacking apachesolr_views.views.inc for testing, when it works out ill create a seperate module or something.
My current data part looks like this:
And it does this only for fields of the type 'datetime'.
Now, as you can see i just used the existing views_handler_filter_date. This gives me the filter, and the option to enter in the date i wish to filter on, but after doing that i get the following error:
Fatal error: Call to undefined method apachesolr_views_query::add_where() in public_html/sites/all/modules/views/handlers/views_handler_filter_date.inc on line 151
Now i am a bit lost in what to do. I looked at other apachesolr_views_handler_filter_*.inc files and saw most of them extended an existing class, ofcourse i can extend the extisting date_handler but i still have no clue about what to do to prevent the same error from happening.
Comment #5
toemaz commentedWell you can't use views_handler_filter_date but instead you need to extend it and make a date filter for apachesolr_views. Check out how the other filter handlers are extending the default views handlers and override the query() function. So this work is a little OO coding, rather than the usual procedural coding.
I'm not a guru on this matter, but I have been trying to do the things you are doing now with my own CCK fields. However, that didn't include a date field yet. Sorry I can't help any further.
Comment #6
scotjam commentedHi, I'm looking to do something really similar to adding a custom filter, but to reflect different currencies, i.e. a drop down list of three options 'GBP', 'USD', and 'Others'. I'm not sure if this is as complicated as the current issue here. Am I best creating a new issue to request support? or just add it here?
So far I've got new fields added to the index, one called 'ss_cck_price_currency', which takes its input from the Money CCK module. I would now like to add a filter which can be exposed to users allowing them to select from either 'GBP', 'USD', and 'Others'.
I think I need to code like this below, but I don't know what I'm missing? I've been updating this post as I've been trying more code out. Here's the latest....
Any advice?
cheers
scotjam
in my custom module...
in extras.views.inc...
in extras_views_handler_filter_currency.inc
Latest update... I've updated to code above since originally posting, and it appears now to work! Though it's all hardcoded.
Can someone kindly check if this looks right? and suggest improvements to avoid hard coding?
Comment #7
kenorb commented+1
Comment #8
kenorb commentedSomething related: #642430: Date argument handlers for created and updated fields, but as arguments.
Comment #9
mvcrelated, but for core node date fields: #595610: Node Creation/Change date filter
Comment #10
kenorb commentedVersion 6.x is no longer supported due to Drupal 6 End of Life. For Drupal 8.x, use Search API Solr Searchinstead.