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.
when using a view with bef_links in exposed filter block, if the view also has contextual filters, bef_links do not use the correct, aliased url path. I believe the issue is that the #bef_path variable is looking at the view display path, where it should be looking at $form['action'], which will already be set by views to be the correct path to the view the exposed filters. Patch attached.
Comments
Comment #1
jim_keller CreditAttribution: jim_keller commentedComment #2
dalinian CreditAttribution: dalinian commentedFabulous!!! Thanks for the patch Jim. Saved me from having to figure it out. This should certainly be implemented in the module.
Comment #3
KarlSheaBEF also throws an error about a missing path when exposed in a Views Content Pane used in a Panel. This patch fixes that, since $form['#action'] is available there also.
Comment #4
KarlSheaComment #5
guillaumev CreditAttribution: guillaumev commentedCan confirm that it is working on my side.
Comment #6
rudins CreditAttribution: rudins commentedThis patch should be modified. Think of multilanguage site with language prefix.
E.g. $form[$field_id]['#bef_path'] for 'bef_links' should use current_path();
Comment #7
mikeker CreditAttribution: mikeker commentedSetting status to NW, based on #6.
Comment #8
pmchristensen CreditAttribution: pmchristensen commentedHave modified this patch, so it also contains the fix from patch https://www.drupal.org/files/issues/bef-pager_index_not_reset-1924822-3....
It is a patch that corrects errors on the page index, which does not reset the index when you click on a link generated through better exposed filter.
My current project is dependent on both patches, but I think that https://www.drupal.org/files/issues/bef-pager_index_not_reset-1924822-3.... should be included in the project right away, because I can not clearly see any use case where it is not desired for the page index to be reset, when a link is clicked.
Comment #9
justindodge CreditAttribution: justindodge commentedThe patch in #8 helped resolve my issue with contextual filters in use, but
1. I couldn't get it to apply to the latest checkout of dev
2. The 'bef_links' case has a condition that is now erroneous I think:
I re-rolled the patch against the latest dev and removed the condition checking for
$this->display->display_options['path']
.Comment #10
justindodge CreditAttribution: justindodge commentedA little note: when I'm using this in combination with the contrib module "Views Block Exposed Filter Block" (allows block displays to put exposed form in blocks which is not normally allowed),
$form['#action']
always seems to be '/' regardless of the page I'm on. So for me, setting#bef_path
tocurrent_path()
covers all bases.I'm not sure if this would work out for all other use cases though, even though I can only think of cases where I want the filter to affect the page I'm on and not go somewhere else. Using current_path() would probably get funky in ajax requests that load the view...but I haven't pondered this too deeply. Unfortunately I don't have enough time to help find a perfect solution, but this will do for me for now.
Comment #11
jamesgrobertson CreditAttribution: jamesgrobertson commentedI re-rolled the patch against the latest 7.x-3.x-dev.
Comment #12
mikeker CreditAttribution: mikeker commentedSeems like a lot of unrelated changes in #11 (whitespace changes, etc.) which makes it harder to review. Can you post a patch with only only the changes related to this issue?
(Coding standards patches are always welcome, btw!)
Comment #13
catFighter CreditAttribution: catFighter commentedi have added patch to version module 7.x-3.0
Comment #14
pamatt CreditAttribution: pamatt commented#13 works fine for me, thanks to you all. This is the exact same patch rolled against 7.x.3.x-dev
Comment #15
pamatt CreditAttribution: pamatt commentedHere is the patch... sorry
Comment #16
pamatt CreditAttribution: pamatt commentedComment #17
mikeker CreditAttribution: mikeker commentedStrange -- when I apply #15, I get a corrupt patch error:
Haven't had time to look into this more closely.
Comment #18
joelpittet@mikeker @pamatt forgot to use --relative when making the patch. Quick fix, open the patch and replace :
sites/all/modules/contrib/better_exposed_filters/
with nothing.Comment #19
pamatt CreditAttribution: pamatt commentedSame patch as #15, rolled against the latest 7.x.3.x-dev version and (hopefully) with corruption problems solved.
Comment #20
mikeker CreditAttribution: mikeker as a volunteer commented@joelpittet, @pamatt: Thanks for the updated patch. However, this patch will give the wrong URL if the exposed filter block is placed on a page that is not the view result.
For example:
The paths for the links in the exposed filter block will be similar to
node/368?field_tags_tid=7
instead ofpath_to_page_display?field_tags_tid=7
.Comment #21
pamatt CreditAttribution: pamatt commentedHere is a new proposed patch, with a slightly different approach. The view's URL and arguments are read directly from the view object and attached to the links. I am using it now for a project I'm working on and it seems to work fine, so far.
Comment #22
pamatt CreditAttribution: pamatt commentedComment #23
jenlamptonNice fix, thanks all for the hard work on this issue! The latest patch works in my testing as well: exposed filters on landing page, results page separate. All aliased appropriately :)
Comment #24
mikeker CreditAttribution: mikeker as a volunteer commentedThank you to everyone that worked on this issue! And my apologies for the delay in reviewing it...
A modified version of #21 has been committed to the 7.x-3.x branch (couple more cases of
#bef_path
and trailing whitespace removed). Tagging so it is not left behind in the D8 port.