Ajax facets & views calls do not respect block UI config overrides implemented by ctools_views

Created on 20 January 2020, almost 5 years ago
Updated 25 October 2023, about 1 year ago

Problem/Motivation

ctools_views provides a cool feature to override views contextual filter value directly through block UI (@see patch https://www.drupal.org/files/issues/2020-01-14/ctools_views-pass_argumen... ), so e.g. you can add a block view display with content type contextual filter, go to node layout builder & put this views block as layout component to a layout section, click component settings button & select contextual filter value directly in the layout builder.

So we can have 1 views display & endless blocks with different display options - we like this & use a lot on our project.

However the ajax implementation is completely broken, so the project idea was to have configurable search pages (panel page as node bundle with enabled custom layout per node). We use facets (ajax filters), views pages, exposed filter as a separate block & this contextual filters & the rest block UI made views overrides weren't considered on ajax calls & views returned bad results or blank html.

Proposed resolution

This is almost dirty hack please don't consider this as think through solution, however it perfectly suits our needs for the project, so idea was to share this to people who also interested in this functionality & to think through the better solution for abstract logic.

How it works & what it does: we have views pre build hook in ctools_views module which is invoked for both ajax views & ajax facets calls, then we find entity from views path & loading a layout for it, then we go through sections until we find views display block section (not separate exposed filters block) & fetch config from there, then we create a stub block instance with this config & use it to process our current views to apply all ctools_views related changes on top of existing views. This way our facets, pager & the rest ajax related views/facets based logic starts working as it should by design.

Remaining tasks

Get rid of garbage, implement tests, think though the task & probably propose a better design.

📌 Task
Status

Needs review

Version

3.2

Component

Code

Created by

🇬🇷Greece Pavel Ruban

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024