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.
Hi Guys, just want to share this patch that I created, At first I thought the problem was my custom filter entry but when I dig inside there was a problem on the line that adds filter from custom filter field. This fixes the custom filter or ADDITIONAL QUERY field not working for MLT blocks settings.
Comment | File | Size | Author |
---|---|---|---|
#15 | mlt-custom-filter-1596308-15.patch | 949 bytes | wulff |
#6 | 1596308-Fix-custom-filter-on-mlt-blocks-settings.patch | 689 bytes | travismark |
#4 | Fix-custom-filter-on-mlt-blocks-settings.patch | 821 bytes | travismark |
Screenshot at 2012-05-23 18:45:14.png | 5.52 KB | travismark | |
Fix-custom-filter-on-mlt-blocks-settings.patch | 836 bytes | travismark | |
Comments
Comment #2
dzieyzone CreditAttribution: dzieyzone commentedFix-custom-filter-on-mlt-blocks-settings.patch queued for re-testing.
Comment #4
travismark CreditAttribution: travismark commentedRevised patch.
Comment #5
travismark CreditAttribution: travismark commented--- a/sites/all/modules/apachesolr/apachesolr_search.module
+++ b/sites/all/modules/apachesolr/apachesolr_search.module
@@ -604,7 +604,11 @@
if ($custom_filters = $settings['mlt_custom_filters']) {
// @todo - fix the settings form to take a comma-delimited set of filters.
- $query->addFilter('', $custom_filters);
+ $custom_filters = explode(',',$custom_filters);
+ foreach ($custom_filters as $custom_filter){
+ list($filter_index, $filter_value) = explode(":",$custom_filter);
+ $query->addFilter($filter_index, $filter_value);
+ }
}
Comment #6
travismark CreditAttribution: travismark commentedComment #7
Nick_vhComment #8
Nick_vhPlease use two spaces instead of a tab.
We might also want to validate the filter before we send it to addFilter. See validFilterValue in solr_base_query.php
Comment #9
Nick_vhThis is not a bug, it's a feature request. It works perfectly without this. Hoping to get some more response from people in this issue
Comment #10
travismark CreditAttribution: travismark commentedHi Nick, Yeah I agree.. just in case some devs need this feature they might stumble in this ticket tand have idea how to make it work. Thanks for you help! :)
Comment #11
travismark CreditAttribution: travismark commentedComment #12
Nick_vhWell, you don't need to close it just yet ;-)
Comment #13
jrreid CreditAttribution: jrreid commentedThis works for me. In fact without it the custom filters don't seem to work for me on the latest 7.x-1.x when I was creating/testing #2017135: Add token for local site hash value. The @todo a few lines up can probably also be removed as this handles that.
Comment #14
pwolanin CreditAttribution: pwolanin commentedComment #15
wulff CreditAttribution: wulff commentedI've been trying to add a date filter to one of our MLT blocks, to make sure that the block only contains fairly recent content:
ds_created:[2008-01-01T00:00:01Z TO *]
With the current version of the module, this results in the following parameter being added to the query string (url decoded):
fq=:"ds_created:[2014-01-01T12:00:00Z TO *]"
This does not seem to work as intended.
After applying a cleaned-up version of the patch in #6, the following parameter is added to the query string (url decoded):
fq=ds_created:[2014-01-01T12:00:00Z TO *]
This seems to work as intended.
I have attached an updated patch.
Comment #16
darvanenUsing the recently updated 7.x-1.7 module, custom filters weren't working **at all**. This patch (#15) fixed it for me.
Comment #17
Den Tweed CreditAttribution: Den Tweed commentedHad same problem with custom filter not working, patch #15 fixed this.
Comment #18
darvanenChanging status to RTBC as #15 now has 3 confirmed uses with no constructive feedback after 9 months. Has been in production for at least 2 months here with no bugs found.
Comment #19
Nick_vhSeems reasonable for me. Will add it to the next release :)
Comment #20
maxocub CreditAttribution: maxocub commented+1
Comment #21
nareshbw CreditAttribution: nareshbw as a volunteer commentedUsed patch # 15 it is working fine for me .
Comment #22
edjeavons CreditAttribution: edjeavons commentedPatch #15 has solved the problem for me as well. Thank you.
Comment #24
janusman CreditAttribution: janusman at Acquia commentedFixed