Problem/Motivation

Some Views displays (such as block displays) do not have a natural path. For these cases, Views provides a 'Link display' setting that allows the display to point to a specific path, including a custom URL. This is particularly important for exposed filter forms. Currently, when an exposed form is rendered for a block display, it ignores the display’s 'Link display' setting and instead falls back to the page display path or the current request path.

Proposed resolution

Update the exposed form so that its action URL respects the display’s 'Link display' setting, including when a custom URL is configured.

Remaining tasks

  • Add or update automated test coverage.
  • Review the patch and iterate as needed.

User interface changes

None.

API changes

None.

Issue fork drupal-1874838

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

itangalo’s picture

Status: Active » Needs review
StatusFileSize
new727 bytes

Patch attached.

itangalo’s picture

There were some related issues about this:

#1023074: Exposed filter forms with block view with a feed display submits to the feed URL
#525592: views_embed_view() + exposed filters button = homepage redirect
#607606: Exposed filter in block always defaults to filtering the feed view

They are either marked as 'closed (works as designed)' or 'fixed'. I think this approach/patch solves the issues.

dawehner’s picture

Thanks for working on this issue! I saw #1329776: Utilize the custom_url/link_url view options in the get_path of the context display which seems to be really similar, so i'm wondering whether we should also check that the link type is custom_url?

itangalo’s picture

@dawehner: It seems to be exactly the same issue. The patch above is against views_plugin_display.inc, so it would affect *all* display types. I think it makes sense, but I really don't know the Views architecture well enough to say what problems might arise.

dawehner’s picture

Status: Needs review » Reviewed & tested by the community
StatusFileSize
new643 bytes

So i guess this is safe to commit. Any objections?

itangalo’s picture

Seems good to me!

dawehner’s picture

Status: Reviewed & tested by the community » Needs review
StatusFileSize
new806 bytes

Perfect. Here is a 8.x version.

Status: Needs review » Needs work

The last submitted patch, drupal-1874838-7.patch, failed testing.

itangalo’s picture

Status: Needs work » Closed (fixed)

It seems this patch, or some code very similar to it, is now in Views core.

olli’s picture

Project: Views (for Drupal 7) » Drupal core
Version: 7.x-3.x-dev » 8.x-dev
Component: exposed filters » views.module
Status: Closed (fixed) » Needs review
Issue tags: +VDC
StatusFileSize
new813 bytes

I can't find #7 in 8.x.

dawehner’s picture

Issue tags: +Needs tests

Good catch! I guess we need to add a test here.

jibran’s picture

10: vdc-1874838-10.patch queued for re-testing.

Prashant.c queued 10: vdc-1874838-10.patch for re-testing.

Status: Needs review » Needs work

The last submitted patch, 10: vdc-1874838-10.patch, failed testing.

Version: 8.0.x-dev » 8.1.x-dev

Drupal 8.0.6 was released on April 6 and is the final bugfix release for the Drupal 8.0.x series. Drupal 8.0.x will not receive any further development aside from security fixes. Drupal 8.1.0-rc1 is now available and sites should prepare to update to 8.1.0.

Bug reports should be targeted against the 8.1.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.2.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.1.x-dev » 8.2.x-dev

Drupal 8.1.9 was released on September 7 and is the final bugfix release for the Drupal 8.1.x series. Drupal 8.1.x will not receive any further development aside from security fixes. Drupal 8.2.0-rc1 is now available and sites should prepare to upgrade to 8.2.0.

Bug reports should be targeted against the 8.2.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.3.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.2.x-dev » 8.3.x-dev

Drupal 8.2.6 was released on February 1, 2017 and is the final full bugfix release for the Drupal 8.2.x series. Drupal 8.2.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.3.0 on April 5, 2017. (Drupal 8.3.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.3.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.4.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.3.x-dev » 8.4.x-dev

Drupal 8.3.6 was released on August 2, 2017 and is the final full bugfix release for the Drupal 8.3.x series. Drupal 8.3.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.4.0 on October 4, 2017. (Drupal 8.4.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.4.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.5.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.4.x-dev » 8.5.x-dev

Drupal 8.4.4 was released on January 3, 2018 and is the final full bugfix release for the Drupal 8.4.x series. Drupal 8.4.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.5.0 on March 7, 2018. (Drupal 8.5.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.5.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.6.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.5.x-dev » 8.6.x-dev

Drupal 8.5.6 was released on August 1, 2018 and is the final bugfix release for the Drupal 8.5.x series. Drupal 8.5.x will not receive any further development aside from security fixes. Sites should prepare to update to 8.6.0 on September 5, 2018. (Drupal 8.6.0-rc1 is available for testing.)

Bug reports should be targeted against the 8.6.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.7.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.6.x-dev » 8.8.x-dev

Drupal 8.6.x will not receive any further development aside from security fixes. Bug reports should be targeted against the 8.8.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.9.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 8.8.x-dev » 8.9.x-dev

Drupal 8.8.7 was released on June 3, 2020 and is the final full bugfix release for the Drupal 8.8.x series. Drupal 8.8.x will not receive any further development aside from security fixes. Sites should prepare to update to Drupal 8.9.0 or Drupal 9.0.0 for ongoing support.

Bug reports should be targeted against the 8.9.x-dev branch from now on, and new development or disruptive changes should be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

pcambra made their first commit to this issue’s fork.

pcambra’s picture

Version: 8.9.x-dev » 9.3.x-dev
Issue summary: View changes
Status: Needs work » Needs review
pcambra’s picture

StatusFileSize
new1.64 KB

Adding a patch to make it easier to include it in composer.json workflows

Version: 9.3.x-dev » 9.4.x-dev

Drupal 9.3.0-rc1 was released on November 26, 2021, which means new developments and disruptive changes should now be targeted for the 9.4.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.4.x-dev » 9.5.x-dev

Drupal 9.4.0-alpha1 was released on May 6, 2022, which means new developments and disruptive changes should now be targeted for the 9.5.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.5.x-dev » 10.1.x-dev

Drupal 9.5.0-beta2 and Drupal 10.0.0-beta2 were released on September 29, 2022, which means new developments and disruptive changes should now be targeted for the 10.1.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

smustgrave’s picture

Status: Needs review » Needs work
Issue tags: +Needs Review Queue Initiative

This issue is being reviewed by the kind folks in Slack, #needs-review-queue-initiative. We are working to keep the size of Needs Review queue [2700+ issues] to around 400 (1 month or less), following Review a patch or merge request as a guide.

For the tests requested in #11

Did not test.

Version: 10.1.x-dev » 11.x-dev

Drupal core is moving towards using a “main” branch. As an interim step, a new 11.x branch has been opened, as Drupal.org infrastructure cannot currently fully support a branch named main. New developments and disruptive changes should now be targeted for the 11.x branch, which currently accepts only minor-version allowed changes. For more information, see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

yannickoo’s picture

I am happy that I found this and never needed to use that in my time working with Drupal - until now :D Even when having the patch applied I cannot see a differen action attribute in the exposed filters forms.

Do you think we should also try to read that configured Custom URL first before taking the <current> URL like this?

$form_action = $view->display_handler->getPath() ?: Url::fromRoute('<current>')->toString();
yannickoo’s picture

Status: Needs work » Needs review
smustgrave’s picture

Status: Needs review » Needs work

MR isn’t pointed to the right branch. And appears to be missing test coverage

yannickoo changed the visibility of the branch 11.x to hidden.

yannickoo’s picture

So we have a new MR now that is against 11.x branch. Tests are still missing.

joelpittet made their first commit to this issue’s fork.

joelpittet’s picture

Issue summary: View changes
Issue tags: -Needs tests

Added tests and touched up the issue summary to remove references to "content panes". I hope that moves this forward a bit.

joelpittet’s picture

Status: Needs work » Needs review

Forgot to set the status

Version: 11.x-dev » main

Drupal core is now using the main branch as the primary development branch. New developments and disruptive changes should now be targeted to the main branch.

Read more in the announcement.

phenaproxima made their first commit to this issue’s fork.

phenaproxima’s picture

Status: Needs review » Reviewed & tested by the community

@catch pointed me to this issue after we argued over #3567584: Update search recipe for Canvas.

This looks like a great solution. I had no idea that "link display" was a thing, or that it supported custom URLs. This appears to solve the problem I opened #3569621: Exposed filter forms should be able to redirect to an arbitrary URI for, albeit in a typically obscure Viewsian way.

I made one tiny change in the MR, which is to use === instead of ==. I don't think that's a substantive enough change that I'm not comfortable RTBCing this.

joelpittet’s picture

Thanks @phenaproxima!

larowlan changed the visibility of the branch 1874838-allow-exposed-blocks to hidden.

larowlan’s picture

Version: main » 11.x-dev
Status: Reviewed & tested by the community » Fixed

Committed to main and backported to 11.x thanks

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

  • larowlan committed f000de8b on 11.x
    feat: #1874838 Allow exposed blocks to use 'Link display' settings
    
    By:...

  • larowlan committed 830d302e on main
    feat: #1874838 Allow exposed blocks to use 'Link display' settings
    
    By:...

Status: Fixed » Closed (fixed)

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