I think there's an issue here. When displaying facets on a none-search page (e.g. a job node for a job search) in combination with the facet API "Force this facet to submit to a specific search page", the #options array in the facets gets all populated with the forces value, i.e. $this->settings->settings['submit_page']
in FacetapiSelectDropdowns.inc.
subsequently the facet dropdown only shows 1 value and dpm($form) for the facet filter shows that #options only have 1 value, of course.
I've come up with a temp fix for me:
if($this->settings->settings['submit_page']){
$base_arg = arg(0);
$current_path = current_path();
if($base_arg != $this->settings->settings['submit_page']){
$item['#path'] = str_replace($current_path, $this->settings->settings['submit_page'], $item['#path']);
}
}
which basically checks if the current page is NOT the same as the $this->settings->settings['submit_page'], if thats the case, rewrite the $item['#path'] of the facet to use the force submit value and not the current path, eg. node/1234.
This is quick as I'm in a rush, and don't think its useful, but maybe can point out the issue for review.
Comment | File | Size | Author |
---|---|---|---|
#16 | facetapi_select_fix_force_submit_bug-2801619-16.patch | 1.01 KB | jlamp |
#2 | 2801619-display-select-dropdown-facets-on-other-pages.patch | 1.01 KB | 4alldigital |
Comments
Comment #2
4alldigital CreditAttribution: 4alldigital commentedComment #3
basvredelingNot sure if this is related but the facetapi_select.js redirects directly to the selection option url without actually submitting the facet form (thereby bypassing any submit and validation handlers). I can think of multiple scenarios where this might be a bad idea. And it sounds a lot like your forced submit url problem.
Comment #4
jlamp CreditAttribution: jlamp at GollyGood Software commentedPatch submitted. This fixes the facetapi_select.js script so that it does not bypass the submit handler.
Comment #6
grndlvl CreditAttribution: grndlvl at GollyGood Software for Zivtech commented@4alldigital
It is not clear as to what problem you are attempting to resolve here. Could you possibly explain you set up a little more? Like how are you displaying the facet on a non-search page and little more about what is happening versus what you expect?
I did however, go ahead and patch the js so that we actually submit the form.
Comment #7
benoit.borrel CreditAttribution: benoit.borrel commented@jlamp, @grndlvl
Patch #4 changes behaviour as it switches from a HTTP Get to a POST. IMHO this is a backward compatibility break. FacetapiUrlProcessorStandard::fetchParams() relies on $_GET, not $_POST. As a result of this patch the posted select value is not taken as a filter by the search.
Comment #9
grndlvl CreditAttribution: grndlvl at GollyGood Software for Zivtech commentedReverted, release 7.x-1.3, and closing this issue. Please open a new task to do any additional work with this task.
Though I find it odd that this did not work considering the submit handler does a drupal_goto()... so it should have worked... I mean if this did not work then the fallback doesn't work.
@benoit.borrel so... what version did you patch against?
Comment #10
grndlvl CreditAttribution: grndlvl at GollyGood Software for Zivtech commentedComment #11
benoit.borrel CreditAttribution: benoit.borrel commented@grndlvl in #9
I didn't patch, I simply updated facetapi_select module from 7.x-1.1 to 7.x-1.2 which includes patch #4.
Comment #12
4alldigital CreditAttribution: 4alldigital commented@grndlvl - sorry for the long delay.
I'm placing facet select dropdowns on job nodes using Panelizer so a user can implement a fresh search/filter from that node and land on the filtered search page. I set the "Force this facet to submit to a specific search page to be the search page e.g.. /opportunities, for each facet.
The scenario I would expect is when selecting the facet options to be redirected from the job page to /search/my-chosen/facet-option.
you can see this working here : http://www.sophiemacpherson.com/opportunities, where I have applied the original patch. Without the patch, the filter just goes to /opportunities. Without the "Force this facet.." options seat the filters simply append the facet filters to the node page.
As I said, I don't know if this is a bug, feature request or I have something misconfigured, but hopefully that helps you... tell me...
Again,.. sorry for delay and thanks for keeping the issue open.
Comment #13
jlamp CreditAttribution: jlamp at GollyGood Software commented@4alldigital
I've taken a look over the codebase and tested it out a bit.
I think the only problem is that you shouldn't have the "/" on the force submit url.
Try changing your force submit url from "/opportunities" to "opportunities", and run it without your patch and see if it runs as expected.If you don't have the time, I'll test it more -- running out the door now. I feel like that's the issue, though. If so, we just need to clean up the force submit url a bit so that it accepts the url with or without the "/".
Comment #14
jlamp CreditAttribution: jlamp at GollyGood Software commentedOk, completely disregard what I said above @4alldigital, lol. I've had more time to look at it and I've identified the problem and have a fix going. I'm going to clean up the code a bit and I should have a patch out for it in just a little bit.
The problem was just that the search was not properly being appended to the force submit URL.
Comment #15
4alldigital CreditAttribution: 4alldigital commentedOk great. nice to know that it was an issue and you know how to fix. nice work. thanks!
Comment #16
jlamp CreditAttribution: jlamp at GollyGood Software commentedPatch submitted. This properly appends the facet's search to the forced submit page.
I've tested it on my own setup and it works (selecting an option on a non-search page will submit that facet's search on the force submit page). Let me know if it fixes your setup too!
Thanks!
Comment #17
jlamp CreditAttribution: jlamp at GollyGood Software commentedComment #18
4alldigital CreditAttribution: 4alldigital commentedIt'll probably be early next week before I get a chance to work on this again. But if still pending, I'll test and feedback. thanks.