Hi, thank you for this amazing module. You all are so awesome, we use this module on so many of our sites.
I have an ajax enabled View with a "Category" taxonomy contextual filter and a "Date" facet that is configured to show "Month" granularity.
I add the view using a block display.
When I initially load the page with the view with a contextual filter present, the right date facet months show up with the right count.
If I click on one of the months, the results for the view get updated correctly but the date facet months show up as if no contextual filter is present.
Thank you so much for looking into this
Comments
Comment #2
swiftsystems commentedComment #3
swiftsystems commentedComment #4
swiftsystems commentedComment #5
swiftsystems commentedComment #6
swiftsystems commentedComment #7
swiftsystems commentedComment #8
todd zebert commentedWorks for our site
Comment #9
bassam commentedThanks for the patch. It worked.
I think this should be added to the module ASAP
Comment #10
borisson_Let's start by putting this issue to needs review, so that the testbot can have a look.
This does not check if this is an ajax-request, so either the comment is not valid, or the code isn't, in any case this is confusing.
Is this a BC break?
You seem to be on drupal.org long enough to know this is not how that works. This issue is still in active, and we haven't seen what tests break with this patch. At the very least this issue should be moved to rtbc, before we add it to the module.
@ccx105 PS: It seems you (like many others – it's really easy to misinterpret) are confused by the "Issue tags" field. As the guidelines state, they aren't meant for free text tags related to the issue, but only for specific categorization purposes, usually by module maintainers. They are certainly not intended to tag with the module name in the module queue.
So, if you aren't sure your current usage is correct, please just leave the field empty.
Comment #11
borisson_Back to needs work for remarks in #10.
Comment #12
allaprishchepa commentedI faced the same problem.
We have a lot of patches for the Facets module, including custom patches (that are not from DO).
So I had to update the patch from #5 and create a new one.
Also, I had to add a patch for ViewsBlock.php because it doesn't include arguments from block configuration.
And we also have a lot of patches for Drupal core, so I'm not sure that it can be relevant for anybody.
Comment #13
swiftsystems commented@borrison_ you're welcome for the help
Comment #14
wellsIn addition to the concerns in #10 the patch in #6 works when selecting filters but does not work when other exposed forms are changed (e.g. exposed sort forms) because
updateFacetsBlocksis also called inDrupal.Ajax.prototype.beforeSendand not updated there to add the view arguments. Seems like getting the args there might be a bit dicey...It seems like it might be preferable to handle the arguments in
Drupal.behaviors.facetsViewsAjaxand maybe add them tosettings.facets_views_ajax? That way they could be accessed byupdateFacetsBlocks(or any other function) without having to pass parameters around or determine DOM/View IDs again.Comment #15
wellsAttaching a patch here with a different approach -- getting the request data in
\Drupal\facets\Plugin\facets\facet_source\SearchApiDisplayseemed a bit off to me so instead this patch attempts to achieve the same result but from\Drupal\facets\Controller\FacetBlockAjaxController::ajaxFacetBlockView(the controller called byupdateFacetsBlocksinfacets-views-ajax.js. My approach is to:Drupal.behaviors.facetsViewsAjax.\Drupal\facets\Controller\FacetBlockAjaxController::ajaxFacetBlockViewto execute the relevant Views.Doing this causes Search API to cache the results and
\Drupal\facets\Plugin\facets\facet_source\SearchApiDisplay::fillFacetsWithResultsalready looks for cached results before attempting to execute the View. It's possible this also removes the need for the condition and View execution handling infillFacetsWithResultsbut I'm not sure if there are other paths that lead to that.This method also supports the use case I have (see #14) -- an AJAX enabled View with facets and an exposed sort.
As this is a different approach than #6 I'm not including an interdiff.
Comment #17
wellsSwitching this to the new 2.0.x branch to see if still applies and passes.
Comment #18
mkalkbrennerYou need to queue the 2.0.x tests manually on these old issues. I did so now.
Comment #19
artem_kondra commentedRewrite the patch to avoid this type of error https://www.drupal.org/project/facets/issues/3310536
Comment #20
yauheni commentedRewrite the patch for 2.0.6