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
- Create 4 contents of any type
- Create a block view to display published nodes. Display only title of each node in view.
- Add a contextual filter for the ID. Select "Content ID from URL" as the default value for the filter
- Place the block in sidebar and view any page
- Block is visible with the title of the current node.
- Edit the same node and select 'Preview' button.
- 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
| Comment | File | Size | Author |
|---|---|---|---|
| #31 | after-MR-patch.png | 384.56 KB | arisen |
| #31 | before-MR-patch.png | 377.48 KB | arisen |
Issue fork drupal-2978024
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:
- 2978024-allow-content-id
changes, plain diff MR !5764
- 2978024-test-only
changes, plain diff MR !5783
Comments
Comment #4
benjamin.merkley commentedHaving the same issue.
Comment #10
esch commentedHaving the same issue.
Comment #11
quietone commentedThis is a fortnightly bug smash triage issue, adding tag. Moving to views so the views maintainers will see this (lendude commented in slack that they had not seen this issue).
Some minor updates to the IS.
Comment #15
dan612 commentedI think this issue can be addressed in the Node module which provides the default argument to views. Patch attached.
Comment #16
harshil_jadav commentedThis Patch #15 Looks Good, I have tested in my local and and it worked.
Comment #17
needs-review-queue-bot commentedThe Needs Review Queue Bot tested this issue.
While you are making the above changes, we recommend that you convert this patch to a merge request. Merge requests are preferred over patches. Be sure to hide the old patch files as well. (Converting an issue to a merge request without other contributions to the issue will not receive credit.)
Comment #18
ameymudras commentedTested #15 and it works absolutely as expected. Only thing that can be an improvement here is using an else if condition rather than if
Comment #20
dan612 commentedelseifas per #18Comment #21
dan612 commentedComment #22
smustgrave commentedIssue summary still needs to be completed.
Also as a bug will need a test case showing the issue
Comment #25
akhil babuComment #26
akhil babuComment #27
akhil babuComment #28
akhil babuAdded test and Updated issue summary
Comment #29
smustgrave commentedAppears to be missing the fix though.
Comment #30
smustgrave commentedNope there it is.
Comment #31
arisenReviewed the MR 5764 and also applied the patch locally. The patch applies cleanly
Reviewed the issue as per the steps.
The issue gets resolved after applying the patch. i.e. Contextual filter(Content ID from URL) gets applied properly on the node preview page.
Attaching the screenshots.
The Assertions added in the Merge Request runs without any failures. RTBC for me.
Comment #33
smustgrave commented@arisen post a screenshot of the patch applying it's needed or useful, we know it applies by the MR being green.
Opening a test only MR is unnecessary so it's hidden.
Running test-only feature of main MR.
So removing tests tag.
Left a comment on the MR.
Comment #34
akhil babuThanks for reviewing @dan612 and @smustgrave. I have updated the condition to
Moving back to needs review
Comment #35
smustgrave commentedBelieve this is now good.
Comment #36
quietone commentedThis issue is changing the UI so adding Usability tag, there should also be screenshots available for reviewers from the Issue Summary.
I then tested this using the steps in the issue summary. I created the problem and then applied the diff and reloaded the preview page. There was no change. After clearing cache the new block was displayed.
I ran the test locally without the fix and it failed as expected. I read the MR which looks fine to me. I also updated credit
Leaving at RTBC
Comment #39
lauriiiCommitted c3c9dd1 and pushed to 11.x. Thanks!