Allow "Content ID from URL" contextual filter to recognize node previews

Created on 7 June 2018, about 7 years ago
Updated 29 January 2024, over 1 year ago

Problem/Motivation

Issue: Currently if you create view block, that uses "Content ID from URL" contextual filter, it will work only when you are viewing a node. When the node is previewed - URL is using UUID, hence the view will won't work.

What is expected: "Content ID from URL" contextual filter must work event if UUID is used instead of ID. Other solution might be creating additional "Content UUID from URL" contextual filter.

Steps to reproduce

  1. Create 4 contents of any type
  2. Create a block view to display published nodes. Display only title of each node in view.
  3. Add a contextual filter for the ID. Select "Content ID from URL" as the default value for the filter
  4. Place the block in sidebar and view any page
  5. Block is visible with the title of the current node.
  6. Edit the same node and select 'Preview' button.
  7. Block is not visible in node preview

Proposed resolution

Update core/modules/node/src/Plugin/views/argument_default/Node.php to get node ID from node preview route.

Remaining tasks

Patch->Done
Add tests->Done
review
commit

User interface changes

None

API changes

None

Data model changes

none

Release notes snippet

๐Ÿ› Bug report
Status

Fixed

Version

11.0 ๐Ÿ”ฅ

Component
Viewsย  โ†’

Last updated about 18 hours ago

Created by

๐Ÿ‡ฐ๐Ÿ‡ฌKyrgyzstan elaman

Live updates comments and jobs are added and updated live.
  • Usability

    Makes Drupal easier to use. Preferred over UX, D7UX, etc.

Missing content requested by

๐Ÿ‡ฆ๐Ÿ‡บAustralia dpi
over 1 year ago
Sign in to follow issues

Merge Requests

Comments & Activities

Production build 0.71.5 2024