-
Notifications
You must be signed in to change notification settings - Fork 132
Fix for being able to relate content from the logged in user ( drupal 8.3 ) #352
Comments
Hi @beerbaitandfishing, I created a PR in #415. This relation might be useful but isn't this issue a duplicate for #254? You'd want to use a contextual filter to list all the content for the current user. |
I thought #254 was more about getting content from groups that a user is a part of. I think this issue is just about being about to get the group node from the og membership entity. I found this issue while I was trying to create a view that showed the groups a user belonged to. The familiar relationship from the the 7.x branch aren't here anymore so I'm a bit lost as to how to create the view. When I add this code, I do see the new 'OG Membership Content' Relation and I have added it, however, I do not get many (any?) additional fields to add to my view. I was expecting to see things like 'title' and the rest of the fields on the group node bundle that I could specify to use the relationship, but they aren't there. I can chose 'rendered entity' but then I have to choose a view mode. I think it would be useful to just render individual fields. |
anyway, for my case, I thought I might as well add another relation, relating the group to the og membership, then the membership to the user, then filtering on the user. I did that by adding this: $data['node']['og_membership']['relationship'] = [ It seems to work well. |
I believe this would indeed be a better and more generic option than the default argument proposed in #254. |
I'm desperately trying to build what I think is a simple view that would show the groups a user is a active member of (visible to anyone viewing the user's profile). But this is turning out to be impossible. I've applied both this PR and #254 and I cannot figure out how to do this. This relationship doesn't appear to actually pull in the expected content fields to the view. I've added relationships user > OG:membership > og membership content but it does not expose the content's fields. The best I can get is a rendered entity and choose the view mode. But I really would like to access individual fields. But the rendered entity seems like the only (clunky) option to achieve what should be a basic feature. |
@cofihouse to get the full relationship with the node content, change the base table for
|
Add the following to the file - modules/contrib/og/og.views.inc
-----Add ------
$data['og_membership']['node']['relationship'] = [
'real field' => 'entity_id',
'base' => 'node',
'base field' => 'nid',
'label' => t('OG Membership Content'),
'title' => t('OG Membership Content'),
'id' => 'standard',
];
Add that under the existing relation between user and og_membership.
Then you should be able to go from user -> og membership -> content ( the group that they're a member of ).
The text was updated successfully, but these errors were encountered: