Fetch "User ID from route context" views' contextual filter for any entity

Created on 27 August 2017, about 7 years ago
Updated 28 July 2023, about 1 year ago

Currently, we can filter a view based on the current viewed user or node entity's uid.

There is a lot of contribs which define entity classes extending Drupal\Core\Entity\ContentEntityBase class. So, they all have getOwnerId() method. For example, commerce module which has product and stores entities or profile module's profile entity.

Suggestion: allow those entities to use "User ID from route context" contextual filter.

Feature request
Status

Needs work

Version

11.0 🔥

Component
User module 

Last updated 1 day ago

Created by

🇪🇪Estonia drugan

Live updates comments and jobs are added and updated live.
  • Needs tests

    The change is currently missing an automated test that fails when run with the original code, and succeeds when the bug has been fixed.

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.

  • The Needs Review Queue Bot tested this issue. It either no longer applies to Drupal core, or fails the Drupal core commit checks. Therefore, this issue status is now "Needs work".

    Apart from a re-roll or rebase, this issue may need more work to address feedback in the issue or MR comments. To progress an issue, incorporate this feedback as part of the process of updating the issue. This helps other contributors to know what is outstanding.

    Consult the Drupal Contributor Guide to find step-by-step guides for working with issues.

  • First commit to issue fork.
  • @bhanu951 opened merge request.
  • Status changed to Needs review over 1 year ago
  • Status changed to Needs work over 1 year ago
  • 🇺🇸United States smustgrave

    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.

    This could use an issue summary update using the default template. Steps to reproduce? Was the suggestion what was used in the solution?

    Taking this setting away seems like it could affect existing views. If so they'll need upgrade paths.

  • 🇺🇸United States tyler-durden

    Hours of searching, and I keep on finding this post so I need to ask some questions.

    I'm converting my site from Drupal 7 to 10, where on D7 I had multiple views with a contextual filter that properly got the userid from the node the block was on, so I could show other nodes from this author. I have spent hours trying to get it to work, is this post stating this is not working in Drupal 10+?

    I have the option, "Also look for a node and use the node author" checked so I'd assume since that option is in there it should be working? This seems to be a feature I'd think many sites would need, so maybe I'm just not doing something right?

    I'd try this patch, but it looks like it has issues now and I'm on 10.1. If this is the patch to try I can help test, as I'm not a programmer but I will help how I can.

  • 🇺🇸United States tyler-durden

    I found a work around, instead of basing my view on node/content, I based it on users and used the authour/user relationship to pull nodes and it works great.

Production build 0.71.5 2024