0

I am trying to set up a view of referenced nodes (entity reference field) of the current viewed (group)node. So when a node is viewed i like to filter all the nodes that point to the current node.

Using the node id from url in contextual filter gives no problems. So far so good.

However i like to only display those referenced nodes where the current logged in user is a member of.

Is this possible using views?

  • Is this (group) node created using Organic Groups module? Are the entity references OG members of the OG group? – Queenvictoria May 3 '14 at 6:57
  • Thank for your help. Yes i make use of the OG module. To be more specific: Content types A and B are both groupnodes and can be referenced to each other by a entity reference field. When a user is member of both groups he must see a link of group type A on group type B and vice versa. This way making it possible to switch between both groups. – Byron May 3 '14 at 10:04
1

Ok Organic Groups. I got a long way with the following recipe. Unfortunately I could not set up an identical environment to yours.

1 Add a Contextual filter on "OG membership: Group ID".

2 When the filter is not available Provide default value "The OG groups of the logged in user ". Leave the concatenator as "+".

3 Under More check "Allow multiple values"

  • "1 Add a Views Relationship (in Advanced) to the current user. 2 A another filter to the View that matches the current user to the Entity References membership field." How do i set up a relationship to the current user, under relationship there is no user category So actually i have two entity reference fields on my groupnodes. One is used to determine groupmembership. The other is pointing to a a different groupnode, as in nodereference. – Byron May 3 '14 at 10:16
  • You're right of course. No user in Relationships. I've updated my answer for Organic Groups and used a contextual filter. YMMV – Queenvictoria May 3 '14 at 13:54
0

Thanks for pointing me the right direction. The next setup is my solution: "1 Add a Contextual filter on "OG membership: Group ID".

2 When the filter is not available Provide default value "The OG groups of the logged in user ". Leave the concatenator as "+".

3 Under More check "Allow multiple values"

4 Add a second contectual filter choose: content:name of the entity reference field

5 Config this filter with provide default value "Current OG group from context"

6 Under More check "Allow multiple values"

7 Add a relationshiop :OG membership from node group

8 Under the contextual filter:"OG membership: Group ID" add the relationship mentioned under 7

Looks like this is working

  • Probably would have been better to accept my solution and update it. But I'm glad you found your fix. – Queenvictoria May 17 '14 at 13:15
0

i edit the text before and working for me

Thanks for pointing me the right direction. The next setup is my solution: "1 Add a Contextual filter on "OG membership: Group ID".

2 When the filter is not available Provide default value "The OG groups of the logged in user ". Leave the concatenator as "+".

3 Under More check "Allow multiple values"

i omitted this step

5 Config this filter with provide default value "Current OG group from context"

6 Under More check "Allow multiple values"

7 Add a relationshiop :OG membership from node group

8 Under the contextual filter:"OG membership: Group ID" add the relationship mentioned under 7

Looks like this is working

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.