I have an apachesolr_view with a "Apache Solr: Search" exposed filter which allows searching by keywords.
Problem is the link to remove a keyword in the "current search" block is incorrect: the keyword is still present in the link.
I found that the reason is that function apachesolr_search_currentsearch_block (in apachesolr_search.module) calls $query->get_path('') with a blank string to remove the existing keys. Problem is that apachesolr_views implementation of get_path() (in apachesolr_views_query.inc) has the following code that ignores any empty parameter, hence does not remove the keys because "empty" returns false on a blank string:
if (!empty($new_keys)) {
$this->set_query($new_keys);
}
So I patched the code by replacing empty with is_null and now the removal links are properly created.
if (!is_null($new_keys)) {
$this->set_query($new_keys);
}
Comment | File | Size | Author |
---|---|---|---|
apachesolr_views_get_path.patch | 739 bytes | dawansv | |
Comments
Comment #1
ptrl CreditAttribution: ptrl commentedIf you remove a search term from the current search the text also gets removed. The text should remain but the term should only be removed.
Comment #2
dawansv CreditAttribution: dawansv commentedHmmm not sure which one should be the expected behavior (clearing or no clearing). Clearing is also the behavior in the /search/apachesolr_search interface: text box gets cleared when you remove the search term.
Comment #3
ptrl CreditAttribution: ptrl commentedChecked the default Apache Solr vs this and it doesn't look like it works the same.
For example I have search on word and term
[x] Word
[x] Term
If I uncheck Word or Term in default apache solr (6-2.x) the other search string remains. But if I do this in apache solr views with this patch and uncheck Term the word also gets cleared.
Comment #4
dawansv CreditAttribution: dawansv commentedOh sorry I didn't understand your first post then. I thought you meant the word got cleared in the search box when unchecking the word... Now I understand you meant when unchecking the term... I confirm this and, yes, that's definitely a bug...
Comment #5
nadu CreditAttribution: nadu commentedIn function apachesolr_search_currentsearch_block() of apachesolr_search.module, I changed
$links[] = theme('apachesolr_unclick_link', $keys, $query->get_path(''), array('query' => $query->get_url_queryvalues()));
to:
$links[] = theme('apachesolr_unclick_link', $keys, $query->get_path(''));
and it works.
Comment #6
ckngConsider proposed solutions so far are all hacks.
Here's my version of 'hack', hope it can give an idea to a proper solution.