I have a selection of groups (Organisations).
In each group are a number of "centres".
Each centre will have some "course" content associated with it. To do this I have a node reference to the centre content from the course content. When a member of a group adds a course, I want only the list of centres that are in their groups to appear.

I am trying to make a view to achieve this. but am struggling to link the logged in user (argument ?) to the posts (centres) in a node. I also want if the site admin is logged in, he will see all "centres".

Any help would be appreciated. I'll sleep on it anyway.

Comments

exobuzz’s picture

I;ve got this working, but I wonder if this is the right way to to things ?

First of all I wonder if a node reference is the best way of linking this data. Should I be using some hierarchy module ?

to get this to work I made a "node view" with

Relatioship:
Organic groups: Group node (post) (required)
Filter:
Node: Type = Centre
Argument:
(Group node (post)) Organic groups: Member of a group
with a default value of logged in user, but wiht php validation with some code

global $user;
if (in_array('administrator',$user->roles) or in_array('site editor',$user->roles)) {
  return false;
} else {
  return true;
}

and if it doesn't validate then "show all values".

I then use this view for the node reference. Does seem a bit of a hacky way to do it though. Would be nice if with user stuff it could be "or is a member of some role" type logic.

exobuzz’s picture

I have another problem now in that if someone is a member of more than one group, they could technically post a course to "group A" for a centre that is in "group b". If i could have it so that when they select the group when "adding content", it refreshed the page, so that I can then display only the centres for the currently selected group.

If anyone could help me with this it would be most appreciated.

seancorrales’s picture

Thanks for detailing the view you created in post #1 - that was just what I was looking for!

I'll give some thought to your question in #2 and see if I can help. Thanks again, exobuzz!

claudiu.cristea’s picture

Issue summary: View changes
Status: Active » Closed (outdated)

This version of Drupal is not supported anymore. If this is still an issue in the 8.x-1.x branch, please open a new up-to-date ticket. Closing.