in the apachesolr_search module and in other hook_block implementations we have code like this:
case 'view':
if (arg(1) == 'apachesolr_search' && apachesolr_has_searched()) {
This makes it so that we can't get the facet blocks in any other context (like for facet driven navigation).
We need to make the visibility settings some other way. Perhaps the hook_block api has a way to do this.
| Comment | File | Size | Author |
|---|---|---|---|
| #30 | 337737-get-path-2.patch | 5.79 KB | David Lesieur |
| #28 | 337737-get-path-1.patch | 6.04 KB | David Lesieur |
| #25 | 337737-get-path.patch | 896 bytes | David Lesieur |
| #17 | apachesolr.diff | 6.31 KB | mikejoconnor |
| #14 | asD6.patch | 7.24 KB | robertdouglass |
Comments
Comment #1
pwolanin commentedYes - this was on my list to talk to you about. On possibility - a helper function that stores a static boolean (in analogy to the has_searched helper)? Elsewhere, code that knows that we are on a search page could set it to TRUE.
Comment #2
Scott Reynolds commentedHere ya go.
Why is it important to make sure its this modules search? Isn't enough to do this:
Not sure what motivates that arg() check specifically, so I took it out. See patch
Comment #3
pwolanin commentedwhy $_REQUEST instead of $_GET?
Also, we can probably check if $response is_null(). The if above will throw warnings.
Comment #4
Scott Reynolds commentedThe PHP $_REQUEST variable contains the contents of both $_GET, $_POST, and $_COOKIE.
The PHP $_REQUEST variable can be used to get the result from form data sent with both the GET and POST methods.
Its more comprehensive. The patch does not use that if statement. My question was what motivates :
why not just
works for me, and it is what this patch does
Comment #5
pwolanin commentedwe only every care about GET, so there is simply no reasn to use REQUEST.
Comment #6
Scott Reynolds commentedK fixed and found a path that I missed. The facet blocks work on my custom search page that doesn't use search api. My search page resides at group/ID/search. The facet blocks work fine there. It decouples the arg() logic from the blocks. Still don't know why orginally the apachesolr_search module had this in its block:
it was added for a reason, does that reason still exist? This patch removes that if statement as its not apparent to me why it is needed. If that arg() logic is there the uid facet block, for instance, only shows up on the search/apachesolr_search page.
Comment #7
robertdouglass commentedarg(1) == 'apachesolr_search' preceded the existence of apachesolr_has_searched(). This patch counts as positive and necessary cruft removal.
Comment #8
pwolanin commentedWe should either make this a class method, or refactor it into a re-usable function.
Also, you must not be patching against the code at the end of the DRUPAL-6--1 branch. the
->get_query()method no longer exists.Comment #9
Scott Reynolds commentedI am using the alpha version, wasn't paying attention to this issue (didn't create it didn't select version). I see its been replaced with
is there a
Comment #10
Scott Reynolds commentedOk this patch is against DRUPAL-6--1.
Notes
1.) In the first hunk I wanted to set the $path = $_GET['q']. But I believe that would include the sort params, which is not what is desired. We want only the keys.
2.) language module had a bug, used get_query instead of get_query_basic. I didn't find an issue for this, but if there is i can reroll with that issues patch
It works well, but I probably should have added some comments around say the first hunk for that first note
Also, the breadcrumbs arn't working. I believe that before this patch they weren't working as before this change and after the $path was exactly the same. If you goto search/apachesolr_search the menu tab isn't highlighted. I believe that is caused by the breadcrumb.
Comment #11
David Lesieur commentedMarked #327833: Allow Override of Core Search Path - /search as duplicate.
Comment #12
robertdouglass commentedRerolled and tested. Seems to work. Code looks much better without those arg(1)s.
Comment #13
robertdouglass commentedHere's an untested D5 patch.
Comment #14
robertdouglass commentedThe D6 patch missed one.
Comment #15
pwolanin commentedThis doesn't really make sense to me - we have now totally separated the facet part from the keyword (searrch key) part, so can't we just use $_GET['q'] everywhere unless we are changing the keywords?
Comment #16
robertdouglass commentedYou might be right, Peter.
Comment #17
mikejoconnor commentedHere is an updated patch. The current patch throws errors if you don't have a search query.
Although this seems to be working for me right now, I wonder how well it will if I try to use faceted terms as part of a url callback, for custom search driven nav pages.
Comment #18
pokadan commentedI need to display the facets as if i have searched for something on a non search page.
Anyone to point me in the right direction ? Do you do a $response = $solr->search(...) and then call apachesolr_facet_block with the response and initial query?
Any comments appreciated..
Thanks
Comment #19
mikejoconnor commentedPoka_dan,
Take a look at the Project module. It has some great code for generating searches for general navigation pages.
Once you get a page callback performing searches, apply the patch in comment # 17, and provide some feedback.
Comment #20
pokadan commentedThanks mikejoconnor,
I managed to do it in my own module by displaying my own blocks and replicating some of the apachesolr_search.module code with some modiffs(where the search query is set and others).
Thanks again.
Comment #21
mikejoconnor commentedI've tested this in two sites, and it seems to be working well. It would be nice to have a little more feedback from anyone else using this.
Comment #22
mikejoconnor commentedDidn't mean to change the status
Comment #23
Scott Reynolds commentedWith the commit of #254565: Integrate with Views front-end this no patch no longer applies. That commit created a method on Solr_Base_Query called get_path(). This logic now needs to reside there. So its a much smaller patch. I imagine the exact same logic can be applied from this patch in that method.
Comment #24
pwolanin commentedwe could probably do this as part of #432946: Query class and sort cleanups
Comment #25
David Lesieur commentedRe-applied the same logic to the new get_path() method.
Comment #26
David Lesieur commentedComment #27
pwolanin commentedI was thinking, perhaps, that the base path would be set when the object is instantiated, rather then here you're doing it repeatedly on demand.
Comment #28
David Lesieur commentedMakes sense... Since using
$_GET['q']at this level does not feels perfectly clean, this new patch also adds a way to explicitly pass on the path. I guess it would be better to use this parameter when possible. I have renamed the$querypathmember to$keysto avoid any confusion.This patch alone is not sufficient to have facet blocks anywhere; it is just an intermediate step.
Comment #29
pwolanin commentedKind of feels like
$_GET['q']should not appear anywhere inside the class.Comment #30
David Lesieur commentedWith this patch, the caller of
apachesolr_drupal_query()is now responsible for defining the base path. In the case of apachesolr_search.module, it is always'search/' . arg(1).Comment #31
pwolanin commentedlooks pretty good at first glance, but will need to test it.
Comment #32
David Lesieur commentedMarked #381076: Base paths in sort/facet blocks as duplicate.
Comment #33
pwolanin commentedcommitted to 6.x - do we need any follow-up in terms of the interface definition?
Comment #34
pwolanin commentedComment #35
Scott Reynolds commentedglad to see my substr strpos logic die :-D very cool
Comment #36
David Lesieur commentedPerhaps we'd like get_base_path()/set_base_path() methods?
Comment #38
emackn commentedSo, If i'm using 6.1.x-dev, how do I change the search path from 'search/apachesolr_search/xxxx' from 'what-I-want/xxx' ?
From looking at the code, I don't see how this is easily doable. Am I missing something simple?
#327833: Allow Override of Core Search Path - /search was marked as a duplicate, but I don't see how anything done in this thread fixes that issue.
Just found this, #524366: Custom Search Path. It's for 6.2.x-dev, but does seem to map out what needs to change.
Comment #39
emackn commentedI manually applied the changes from #524366: Custom Search Path and got my search url from
'search/apachesolr_search/xxx'
to
'search/what-i-want/xxx'