Test case:

I'm using a Search Api powered View, built according to the following spec:

  • A search index view, with one page display.
  • Path is set to: 'topic/%'
  • '%' provides a contextual filter argument 'Indexed Node: Topic' (referencing a taxonomy term id)
  • Three facet blocks displayed on same page, using 'Ajax Links' style.

Example results:

  1. ACTION: Load view page display in browser 'http://example.com/topic/24'
  2. View results are limited to term selected via contextual filter (expected behaviour)
  3. ACTION: Toggle facets on (active)
  4. View results are filtered according to activated facets (expected behaviour)
  5. ACTION: Toggle all facets off (in-active)
  6. View returns all rows, disregarding the contextual filter argument in the URL (unexpected behaviour)

It appears that ajax_facets is ignoring the contextual filters arguments that have been applied to the view. I need to find a way to use contextual filters with ajax_facets.

Any help appreciated.

Thanks for a great module.

Luke

Comments

lukus’s picture

Issue summary: View changes

  • eugene.ilyin committed fd436e1 on 7.x-3.x
    Issue #2480557: Views contextual filter arguments aren't respected when...
eugene.ilyin’s picture

Status: Active » Fixed

Hello Lukus!

Thank you for your report.
I corrected this problem in 7.x-3.x

maximpodorov’s picture

Status: Fixed » Active

No, this solution is broken. After applying this patch, my site gets the following errors (selector widget is used):

Notice: Undefined index: view_name in function ajax_facets_refresh_facets_content() (line 21 in ajax_facets/ajax_facets.pages.inc).
Notice: Undefined index: view_display_id in function ajax_facets_refresh_facets_content() (line 22 in ajax_facets/ajax_facets.pages.inc).

Неаккуратно как-то. :)

eugene.ilyin’s picture

@Maxim, can you provide more details? I mean how is your search is organized? Because on my test environment it works well.

P.S. did you cleared the JS cache?

maximpodorov’s picture

It's just a normal search with search api view with facets built in Page Manager.

maximpodorov’s picture

Oh, I see this patch requires that the view has "Use Ajax" setting enabled.

  • eugene.ilyin committed cac1306 on 7.x-3.x
    Issue #2480557 by maximpodorov, lukus: Views contextual filter arguments...
eugene.ilyin’s picture

Status: Active » Fixed

Now it should work for both modes of view (ajax/not ajax).

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

eugene.ilyin’s picture

eugene.ilyin’s picture

pradeepjha’s picture

Still contextual paths are not getting taken. It's still taking path before contextual arguments. First time it'll filter with taking contextual path but from next item selection ( multiselect link facet filter ) it'll exclude that path.

pradeepjha’s picture

Status: Closed (fixed) » Active
eugene.ilyin’s picture

Status: Active » Postponed (maintainer needs more info)

Please explain how to reproduce the problem. Step by step.

mvdve’s picture

Status: Postponed (maintainer needs more info) » Needs review
StatusFileSize
new7.29 KB

Opening this ticket again as i am having the same issue.

When no contextual filter is used, everything works excellent. The issue is that with a contextual filter, (for example when the views page path is taxonomy/term/% or when the taxonomy_display module is used) the getSearchPath() function from the facet adapter will return the views system path and not the actual path when the ajax call made. (so it wil return taxonomy/term/% instead of taxonomy/term/11919). On the first load of the view/page, the correct path is loaded.

I fixed this by moving the collecting of the settings variables to the pre_render hook together with the add_js functions. The view itself can return the path as the getSearchPath() function, but also the full url which is the correct one.

One issue remains: When the taxonomy_display module is used to override a the taxonomy bundle overview, the path of the view is returned instead of the taxonomy path. Not sure if this is an issue which we should fix within this module.

Also solved within this patch: When a contextual filter is used, the view args will be an array instead of a string.

mvdve’s picture

mvdve’s picture

StatusFileSize
new7.25 KB

Updated the patch so that it works on the latest dev version.

mvdve’s picture

Would really appreciate it when someone would be able to review the patch.

candelas’s picture

@mvdve I tried your patch, but it doesn't work with last dev because another code has gone into the ajax_facets.module

candelas’s picture

Also to say that current dev doesn't respect views contextual filters. Thanks for all your work :)

mvdve’s picture

Hi candelas, thanks for testing, i will update the patch later today.

candelas’s picture

Tomorrow morning I will be able to test it. Then I have to finish the site. Thanks

mvdve’s picture

StatusFileSize
new7.25 KB

Had to do some searching (commit 12ce78c broke this patch) but it is working again on the latest 3.x branch.

candelas’s picture

@mvdve the patch in #24 doesn't apply to the last dev

git clone --branch 7.x-3.x https://git.drupal.org/project/ajax_facets.git

patch -p1 < incorrect_path_contextual_filter-2480557-24.patch
patching file ajax_facets.module
Reversed (or previously applied) patch detected! Assume -R? [n] n
Apply anyway? [n] y
Hunk #1 FAILED at 95.
Hunk #2 succeeded at 316 (offset 3 lines).
1 out of 2 hunks FAILED

Anyway, I applied by hand and re-save all facets with facet_ajax links. When I search in the view, facets take the right values, but when I click one facet, the page don't change and all facets are gone. I tried with the view with and without ajax with the same effect.

Also, breadcrumbs, where selected facets show, disappear from the views page.

Thanks for your work :)

mvdve’s picture

StatusFileSize
new7.76 KB

Created a new patch which should work (sorry, the last one had halve the update).

The disappearing of the breadcrumbs is a bit strange. They have nothing to do with facets and the views ajax call.