Add views contextual filter to get group ID from URL or group content 2.x

Created on 10 July 2023, almost 2 years ago
Updated 20 August 2024, 8 months ago

Re-post of #3112501 Add views contextual filter to get group ID from either URL or group content β†’ to update for Group 2.x branch.

I have a site that relies on the original 1.x patch that needs to be upgraded to Group 2.x. This issue provides a patch for the 2.x version of Group. While there is a separate issue to add contexts ( #2815971 More contexts needed πŸ“Œ More contexts needed Needs work ), this patch allows Group 1.x users relying on the patch in #3112501 to upgrade without any additional configuration changes.

I'm posting this as a new issue since the old one was closed prematurely, without being committed to an official release, and I want to make sure this gets seen. There was a request to re-open #3112501 in the comments, but that appears to have been overlooked. I'd be happy to have this issue merged in with #3112501 if it were to be re-opened.

✨ Feature request
Status

Needs review

Version

2.1

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States daletrexel Minnesota, USA

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

Comments & Activities

  • Issue created by @daletrexel
  • πŸ‡ΊπŸ‡ΈUnited States daletrexel Minnesota, USA

    Adding patch.

    The only change needed (as far as I can tell), is to replace
    \Drupal\group\Entity\GroupContent::loadByEntity($entity)
    with
    \Drupal\group\Entity\GroupRelationship::loadByEntity($entity)

  • Status changed to Needs review 8 months ago
  • πŸ‡§πŸ‡·Brazil carolpettirossi Campinas - SP

    Thanks for the patch @daletrexel. It helped me achieve what I needed on my project.

    The scenario is:
    1. The user access the node itself and not the group content URL, so, in this case, the Group is not in the URL
    2. I need to add a Related Items section with content from the same group

    It would be great to have the maintainer reviewing this patch. I'll move to Needs Review.

Production build 0.71.5 2024