I've got a view of nodes that I'm trying to filter based on a property of the group node associated with each node, but I can't build the proper chain of relationships in Views. I can relate the node to its group membership entity, and in turn relate the membership entity to its group entity, but there doesn't seem to be a way to relate the group entity to the group node.

Am I going about this all wrong?

Comments

nagiek’s picture

I'd like to do the same thing. To me, the relationships seem obvious, but I don't think views can recognize them.

henrijs.seso’s picture

Same here. Would like to list group posts and group entity titles in same table.

henrijs.seso’s picture

This issue states that it is possible... #1006860: Allow views 'relationships' from group to group type and from group content type to group Will try to test, but I'm sceptical since I have tried to do it for 3 hours :)

nagiek’s picture

Title: Can't build views relationship from a member node to its parent group node » Can't build views relationship from a group entity to its base entity

@mansspams
The issue here is that the relationship is one-way. You can get the group from the entity, but you cannot get the entity from the group. For most people, it's probably not a problem unless they need to go from group to node to group in their relationships (like me, urgh :$)

If you check the og page, there's a video by bjlewis2 on how to do what you want. It's a great walkthrough.
Linking again for convenience. http://modulesunraveled.com/organic-groups

To me though, it seems like this issue is going to be postponed until a general Entity API solution is found. I would check the issue queue there for progress.

henrijs.seso’s picture

I was thinking that if there is a database table where both values are in same row, there should not be big problem to create relationships both ways and there is table 'og_membership' with all the info needed. How I wish I could write code better :(

amitaibu’s picture

@mansspams,
Can you show a short table of the data you want to present, as example, to better understand you needs.

henrijs.seso’s picture

I have a view listing group post node titles in column A and I want to add column B with group node titles. How to set up relationships for this view? In perfect world from group post node I would make relationship #1 to group and relationship #2 to group node. In result I would be able to add title (or any other field from group node) and just select last relationship in display settings and views would display it in column B. All this should happen without Contextual filters.

Without it I have to do terrible things and kill kittens (like writting $result = db_query("SELECT etid FROM {og} WHERE gid = :gid", array(':gid' => trim($content['gid']))); where $content['gid'] is HTML outputted by views) in theme just to demonstrate og in site ;)

henrijs.seso’s picture

StatusFileSize
new58.41 KB

Here is visualization of that table...

nagiek’s picture

Ah, then yes, you have the same node -> group -> node problem as me.

@Amitaibu
This would be a bit of work, but why not create a dependency using Relation (http://drupal.org/project/Relation) an Entity Reference Field (http://drupal.org/project/ref_field) to build the relationships? Seems like it would save you effort in the long run, since OG Views would become obsolete.

karens’s picture

I'm stuck here too and the ability to do a view of group content that includes both the group page node and the 'parent' group node seems like an obvious need. I have a 'group' content type that is the group entity. I have pages in the groups that are other content types. I need to display some information from the 'group' in a view of the pages. In this particular case, the group has an image field and I want that image displayed in a view of the group pages. The only workaround I've come up with is to go into the node view using hook_preprocess_node and add information from the parent group to the $variables, then create a custom node template that displays them. But that is a lot of work and it doesn't help on a view of fields, which is what I really need. This was easy to do in D6, so it feels like a regression that it can't be done in D7.

Not sure how to solve the problem though. It feels like the 'og' relationship should behave like the nodereference field relationship to join in the tables we need and make them available as sources for fields and filters, so you can say you want to see the title or some other field from the group entity brought in by the OG relationship.

jody lynn’s picture

After fighting for hours with all the relationships, I'm relieved to hear it's not just me.

tim.plunkett’s picture

Not sure if this is still a support request, but leaving for now.

amitaibu’s picture

> This was easy to do in D6, so it feels like a regression that it can't be done in D7.

Indeed. This is because, unlike D6, OG group and OG membership are different entities. I think what is missing is a reverse relationship, (i.e. get node from group) -- it probably should go in og_views_data_alter(), although the best thing would have been able to get this automatically via entity-metadata - maybe improving #1066398: Reverse entity relationships for Views integration

skyredwang’s picture

Category: support » feature

yeah, the current D7 OG Views integration is much less powerful than the D6 one. Therefore, I change the issue to feature request.

karens’s picture

I was thinking the same thing, a variation of views_handler_relationship_entity_reverse. We can't use that because it is very field-specific, but something like that to bring the reverse relationships into a view is what we want I think. I poked around with it but didn't get anything actually working. The code to look at as an example is in Views, in views/modules/field/views_handler_relationship_entity_reverse.inc.

karens’s picture

Or yes, somehow getting this automatically through Entity API. But I wasn't able to figure out what was needed there either :(

nagiek’s picture

I created an issue in Entity API. See the response here: #1288844: Merge Relation with Entity API. Is there a proper implementation of entity-property-info in OG?

CarbonPig’s picture

subscribe

mortendk’s picture

sub

nagiek’s picture

Priority: Normal » Major

@Amitaibu

Since #1066398: Reverse entity relationships for Views integration was committed, any chance of seeing the effects in OG?

casey’s picture

Ran into this issue too while upgrading a - D5, skipping D6 :) - site.

/Edit
Getting this to work is actually pretty tricky. Any entity type can potentially be a group. Entity types have their own base table however, so a simple reverse relationship isn't going to work.

/Edit
Or maybe it does. just add relationships for every entity type that is a group (has a group field).

casey’s picture

Status: Active » Needs review
StatusFileSize
new1.42 KB

Something like this? In most cases you need to setup multiple relations for it to be useful.

nagiek’s picture

Status: Needs review » Active

Also, if anyone is interested in a temporary hack, here's the relationship code for Group to Node only. Paste it in og.views.inc in the og_views_data_alter() function after

  // TODO: This should be handled by entity-metadata.
  foreach (entity_get_info() as $entity_type => $info) {
    if (!empty($info['fieldable'])) {

Temporary code:

      // Reverse group-to-node relationship.
       if ($entity_type == 'node') {
        $title = t('Reverse @entity group', array('@entity' => ucfirst($info['label'])));
        $help = t('Add information on the base @entity from the group.', array('@entity' => ucfirst($info['label'])));
        $data['og']['reverse_og_rel'] = array(
          'group' => t('Group'),
          'title' => $title,
          'help' => $help,
          'relationship' => array(
            // Pass the entity to the handler.
            'entity' => 'og',
            'handler' => 'views_handler_relationship',
            'label' => t($info['label']),
            'base' => $entity_type,
            'base field' => $info['entity keys']['id'],
            'relationship field' => 'etid',
          ),
        );
      }

Would always prefer to have Entity API take this over.

nagiek’s picture

Status: Active » Needs review

whoops. I guess we decided to fix this at the same time! I like the $is_group_type check.

bjalford’s picture

tested patch in #22 and worked fine.

les lim’s picture

Briefly tested #22 in a simple environment with only a single group type - worked fine for both User membership views and Node membership views. Haven't tested any more complex configurations. Nice work!

Structurally, I don't see any reason why we couldn't place the relationship definition within the foreach loop.

amitaibu’s picture

Status: Needs review » Needs work

Thanks casey.

+++ b/includes/og.views.incundefined
@@ -134,6 +134,30 @@
+      $is_group_type = FALSE;
+      foreach ($info['bundles'] as $bundle_name => $bundle_info) {
+        if (og_is_group_type($entity_type, $bundle_name)) {
+          $is_group_type = TRUE;
+          break;
+        }

Instead of this check you can use og_get_all_group_entity().

+++ b/includes/og.views.incundefined
@@ -134,6 +134,30 @@
+          'help' => t('TODO'),

Maybe: Relate an entity to its group entity.

nagiek’s picture

We should do the same thing for group membership info too. Might be a bit harder because you can have both nodes and users.

holtzermann17’s picture

I'm sorry to say I don't think the patches are working for me. I keep getting "There is no content in this group."

wjaspers’s picture

#22 works for me.

Look for a relationship on the "group membership" relationship with a "TODO" description.
Then you can add arguments or fields as needed from the source entity.

tim.plunkett’s picture

Status: Needs work » Needs review
StatusFileSize
new1.46 KB

Reroll of #22 with the feedback from #27.

penguininja’s picture

The patch in #31 works for me. For others trying to reproduce, these were the steps I followed:

  1. Created a new view
  2. Added the "Group: Node group" relationship
  3. Added the "(group) OG group: Og group ID" contextual filter, with "Provide Default Value" of "Current OG group from context"
  4. Added fields to the view (in my case og_node_links, which are added as fields onto group nodes

The result was that I could feed the view a group id and get the group node entity in return. Thanks!

amitaibu’s picture

Status: Needs review » Fixed

Committed, thanks.

I wonder if it helps achieving #8, though.

willkaxu’s picture

It seems too hard to tell views the "GID". Glad to see the patch, I will try it asap.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

pdcarto’s picture

This has saved my bacon, big time! Thank you so much @casey and @tim.plunkett!!!

nagiek’s picture

StatusFileSize
new763 bytes

Can we add the membership->user relationship too?

restyler’s picture

That's super cool addition to og, but it required me 1 hour to figure out how to fetch og group title, taking into account my 5 year experience with views
(I was building very simple view: group post title / group title - but I needed to list posts only from groups of node type "corporate blog" )

I had to enable views sql debug to figure out the final mix of relationships:

1) OG membership: OG membership from Node
2) (OG membership from node) OG membership: OG group gid
3) (OG group) OG group: Node from OG group

I hope that helps somebody who finds the topic.

may be it's just not my day, but I really think this is something impossible for ordinary user to figure out without step-by-step manuals.

skyredwang’s picture

well, for the advanced usage like this, the site builder needs to understand database. It's not built for ordinary users.

Saoirse1916’s picture

Is there any way to use the method in #38 to get additional fields from the group? I've created my groups such that I'm using a building ID for the group title, then an additional field called Building Name. I'd like to get both fields into my view, but this method only exposes the building ID in the form of (OG group) OG group: Label.

The odd part is that in the list of Content fields both Content: Group and Content: Building Name fields are available even without the relationship. However, neither of them actually display any data (with or without the relationships).

jferrervalls’s picture

Thank you "restyler" for your method in ( #38).
Your relationship chain worked fine for me.
I've been trying to do that all day long and was really starting to doubt it was possible in the views UI.

Thanks for sharing

robwithhair’s picture

#31 worked for me although my relationships looked like this.

Group membership: Node group membership
(group membership) OG membership: Group gid
(OG group) Group: Node being the group

juan.pinedaf’s picture

#31
Worked for me.

We have companies content type set as groups and then diff entities linking to the groups.

I needed to show in a view a table with content from the company node + article node

So now I'm able to set the relationship from my article all the way up to the group and also get the group node information, then I can set the fields as being from the company instead of from the article content type.

My relationships:
Group membership: Content group membership
(group membership from article doc) OG membership: Group gid
(OG group company where article belongs) Group: Content being the group

Thank you again guys!

liquidcms’s picture

Version: 7.x-1.0 » 7.x-2.x-dev
Category: feature » bug
Status: Closed (fixed) » Active

has this gotten lost/broken in 2.x?

i simply want to know the group my post is located in. i no longer see Group: Node relationships but do have Entity Relationships like: A bridge to the Content entity that is referenced via og_group_ref

but this doesn't seem to do anything.

DruDoc’s picture

Status: Active » Fixed

@liquidcms
Can you please provide some more information.
In 2.x the views setting will look like this:

Contextual filters
(Group node from OG membership) Content: Nid

Relationships
OG membership: OG membership from Node
(group membership) OG membership: Group Node from OG membership

DruDoc’s picture

Category: bug » support

No bug

liquidcms’s picture

@DruDoc, yes, that's part of the trick, thanks.. didn't realize that since going to 2.x the relationships are now hierarchical? so don't see the 2nd set until i add OG membership: OG membership from Node

also, for the case i was asking about... how to know a group content node's group node, i think the contextual filter part is just:

Content: Nid

not:

(Group node from OG membership) Content: Nid

since i am on the node not the group.

but, this still isn't complete if i want to recreate the simple block that came with D6 which is list group content creation links "within" a group since this only works on group content nodes; doesn't work on the actual group node itself.. i guess i need an OR in here somewhere.

and of course i'd still need a way to list all content types that can be added to a group.. ugghh.. probably still just easier to do this in code (and replicate the code that came with D6)

i am sure i am still getting accustomed to D7 OG; but wow.. this sure is much more convoluted than in D6.

i'll leave this as fixed as this was original question i believe and i do see now "how to get group from a group content node"; but real question should have been simply; how to tell group context? (which in D6 was known on group content or the group node itself)

liquidcms’s picture

Status: Fixed » Active

so, is the "bug" here simply that this relationship: OG membership: OG membership from Node fails on the Group node?

in other words should the group node not be a member of the group?

DruDoc’s picture

StatusFileSize
new108.75 KB

The screenshot might help :)

liquidcms’s picture

Status: Active » Fixed

since this works for group content nodes (but not group nodes); i'll raise a separate issue for that.

jferrervalls’s picture

I was using #38 relationship chain succesfully until something broke :

1) OG membership: OG membership from Node
2) (OG membership from node) OG membership: OG group gid
3) (OG group) OG group: Node from OG group

I now have the following error in the views UI:

1) OG membership: OG membership from Node
2) (OG membership from node) OG membership: OG group gid
3) (Groupe OG) Broken/missing handler

For some reason the 'Node from OG group' relationship does not appear in the list anymore.
I know someone else has made changes on that site (maybe a og update, it's now 7x-1.3 version in used )

Does someone knows witch version of OG GROUP I should use to find this relation back ?

MauPalantir’s picture

Same problem here....

spacereactor’s picture

#45 can't get it to work in content pane. Any help? My goal is to display a list of other group content posts under the same group when viewing a group content.
using og 7.x-2.x-dev

View content pane setting
Contextual filters
(Group node from OG membership) Content: Nid

Relationships
OG membership: OG membership from Node
(OG membership from node) OG membership: Group Node from OG membership

Argument input
Content: Nid source = From context
Required context = Node - Content ID

===========================
Panes Node template setting
Selection rule = OG: Node is an OG group content

DruDoc’s picture

@spacereactor
In panel relationships add "Node from Node (on Node: Group membership [og_group_ref])" and select this relationship for providing the context.

You only need these in your pane views:
Contextual filters
(OG membership from node) OG membership: Group ID
Relationships
OG membership: OG membership from Node

and Argument input: from context - node: Content ID

spacereactor’s picture

Thank DruDoc I manage to display other group post but it also display the current node content in the group content display twice.

I try to add another Contextual filters to exclude the current node but it doesn't work

DruDoc’s picture

In the pane view, did you filter by content type (
Filter criteria
Content: Published (Yes)
Content: Type (= Your Group content(s))

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

boby_ui’s picture

Version: 7.x-2.x-dev » 7.x-1.3
StatusFileSize
new62.72 KB

Hi,

I have the same problem here I am trying to show all the content list and showing the group id/ group name the contents are associated too, I have been trying for hours and finally it is showing I am using the Group membership: Node group membership relationships and I managed to show the (group membership) OG membership: Group gid field. I am using 7.x-1.3 version.

one bug or problem I am facing, if in the content type for that field I enabled the entity translation :
Field translation:
This field is shared among the entity translations. Enable translation

suddenly all the gid's disappeared when I do the new creations/update the content.. but when I disable the translation fields in the content type for that field, when I do the content update it is back again.

I can not get this to work? can someone please lead the way. I am trying to achieve showing list of node filter by content type and by groups they are associated and when user change language it will show the translated content in the correct groups.

I am attaching the screenshot of my config.

thank you

boby_ui’s picture

Status: Closed (fixed) » Active
StatusFileSize
new62.72 KB

Hi,

I have the same problem here I am trying to show all the content list and showing the group id/ group name the contents are associated too, I have been trying for hours and finally it is showing I am using the Group membership: Node group membership relationships and I managed to show the (group membership) OG membership: Group gid field. I am using 7.x-1.3 version.

one bug or problem I am facing, if in the content type for that field I enabled the entity translation :
Field translation:
This field is shared among the entity translations. Enable translation

suddenly all the gid's disappeared when I do the new creations/update the content.. but when I disable the translation fields in the content type for that field, when I do the content update it is back again.

I can not get this to work? can someone please lead the way. I am trying to achieve showing list of node filter by content type and by groups they are associated and when user change language it will show the translated content in the correct groups.

I am attaching the screenshot of my config.

DruDoc’s picture

@boby
there is no contextual filter selected in your views.

boby_ui’s picture

Hi DruDoc,

I need to list them without using contextual filter? can I do that?

thank you

DruDoc’s picture

Of course you can do that, but it means that your issue is probably not related to the original issue posted here. May be you should start a new issue. I do not have any idea about 'entity translation'. Could this be an issue with that module?

boby_ui’s picture

let me recreate the new issues, I don't really understand is it related or not, what I can check is, if it is translated using the field translation, then the results will have ['und'] for the language, and if it is translated, then it will have ['en'], and then the views will stop working. it will not pull any results of the group id anymore.

codemuncher’s picture

These settings finally worked for me:

Contextual filters:
OG membership: OG group gid

Relationships:
OG membership: OG membership from Node
(OG membership from node) OG membership: Node from OG membership

It's important to realize that you first need to add "OG membership from Node" first otherwise "Node from OG membership" will not be there and you won't have the ability to establish a relation with the fields (or content) of the nodes you're trying to show.

kristen pol’s picture

Why is this so complicated??? argh...

Ok, I tried #64 but it doesn't work for me... I've pasted what I have used:

Contextual filters:
(OG membership from node) OG membership: Group ID

Relationships:
OG membership: OG membership from Content
(OG membership from node) OG membership: Content from OG membership

Help? I'll send a free Drupal 7 Multilingual Sites book to whoever points out the error of my ways :)

kristen pol’s picture

I got the group's posted content to show up via:

Relationships:
OG membership: OG membership from Content
(OG membership from content) OG membership: Group Content from OG membership

which isn't what I want but at least I got something! :P

What I want is the main group node. I'll keep trying stuff.

Update1

I did eventually get the same results as above using:

Relationships:
OG membership: OG membership from Content
(OG membership from content) OG membership: Content from OG membership

using a fresh view (rather than a cloned OG view).

I don't know why "Group Content from OG membership" and "Content from OG membership" are both there if they yield equivalent results.

Update2

Now I'm getting the same results with just:

Relationships:
OG membership: OG membership from Content

and no other relationships... ??? I'm so confused o_O

Update3

Maybe someone could post some views code for some of these scenarios?

Update4

I've made progress... I hadn't chosen the relationship for my title, e.g.

(Group node from OG membership) Content: Title

so there is hope now! I see the light at the end of the tunnel... sounds like a good blog post.

kristen pol’s picture

Problem

Want to show some information in a view that comes from the main group node.

Solution

  1. Create a new view
  2. Choose to use fields rather than content (it will default to showing the Content: Title)
  3. Add the relationship OG membership: OG membership from Content
  4. Add the relationship OG membership: Group Content from OG membership and choose to use the previous relationship OG membership from node
  5. Add the contextual filter OG membership: Group ID which will default to using the relationship OG membership from node
  6. At this point, you should see all the group's posts listed
  7. Edit the Content: Title field and choose the Group node from OG membership relationship
  8. At this point, you should see the main group node's title (multiple times because you see one for each group post), so we need to get rid of duplicates
  9. Click Settings under Query settings and choose Distinct and Pure distinct
  10. Now you should only see the group node's title once

So... I'm wondering now if this is really the best way to do this? It seems rather complex.

liquidcms’s picture

yes, i agree completely... lots of people i think are having issues with this because the chain required to set this up is far more complex than it needs to be.

codemuncher’s picture

Ya it's complicated but, trying to do the query yourself will lead to things that will break at some point. Views helps you with avoid these problems. The better way would be to create a specialized field, like the fields Organic Group comes with. But that could take longer.

Kirschbaum’s picture

Kristen Pol's overview of the solution seems like exactly what I need. Unfortunately, it looks like OG/Views has changed the names of some of the relationships and contextual filters in the last couple months. Is anyone able to get this working with the most recent release of OG/Views?

cangeceiro’s picture

Ive been struggling with this for a few hours now, I have a table view that lists content, and i want to add a column that shows what OG it is associated with. None of the suggestions listed here seem to have worked. Closest I have got is the suggestion in #67, but the second title field shows the title of the node and not the OG node like one would expect. And the title field is using the relationship.

colin_young’s picture

I was able to get my related group following the steps in #67, but I was still getting duplicates. Finally figured out that it was the sorting by post date that was not using a relationship and therefore returning 1 row for each group content item. Adding the relationship there fixed it up for me.

Thanks to all in this thread for all the details and work in getting this scenario working.

Colin

d0t15t’s picture

does the method from #67 work for og7.x-1?
the relationship from step 4: OG membership: Group Content from OG membership seems to be missing...

MauPalantir’s picture

Well, it seems that currently there is an odd behavior in og.views.inc @ line 67 (in views_data_alter()):

  $group_content_entities = og_get_all_group_content_entity();
  foreach (entity_get_info() as $entity_type => $info) {
    if (empty($group_content_entities[$entity_type])) {
       continue;
    }
    // OG membership relationship.
    $data[$info['base table']]['og_membership_rel'] = array(
      'group' => t('OG membership'),
      'title' => t('OG membership from @entity', array('@entity' => ucfirst($info['label']))),
      'help' => t('The OG membership associated with the @entity entity.', array('@entity' => ucfirst($info['label']))),
      'relationship' => array(
        // Pass the entity to the handler.
        'entity' => $entity_type,
        'handler' => 'og_handler_relationship',
        'label' => t('OG membership from @entity', array('@entity' => $entity_type)),
        'base' => 'og_membership',
        'base field' => 'etid',
        'relationship field' => $info['entity keys']['id'],
      ),
    );
…

And then come all the OG membership relations for that entity type, including the ones that define Group @entity from OG Membership.
As far as I can see, og_get_all_group_content_entity() returns with only the entity types that can be a group content,
so if, for example, you have some group node types but no node types that can be a group content, then Node entities will not appear in Views
as possible group entities.

In my use case, I had a custom entity type (Record) that were organized with group Nodes, but there were no node types can could be group content, so no OG viws relationships were generated for node entities, even though I had properly functioning group nodes.

I temporarily disabled this check, and thus I have all entity types as possible groups (but this got me some nonsense like
a relationship of possible Group Files, so I guess the proper solution would be that the function checked for whether the entity type
can be a group content OR a group, and add available relations accordingly)

seaneffel’s picture

Status: Closed (works as designed) » Active

I have the answer to the original post.

It takes three cascading relationships to display a node and its related group in one row of a view:

1. Add relationship "OG membership: OG membership from Node"
2. Add relationship "OG membership: OG group gid" and set it to depend on the prior relationship (see #1).
3. Add relationship "OG group: Node from OG group" and set it to depend on the prior relationship (see #2).

Then I add the "Content: Title" field and set this field dependent on the last relationship (see #3). Seeing that that works you can add a filter using the same relationship. I can't speak to the issue of distinct rows, I have not tested that.

The module works fine and doesn't require any patches. But it does beg for some simplicity, or at least a clear answer to help someone when they run into this trouble. Marking this issue as fixed.

seaneffel’s picture

Status: Active » Closed (works as designed)

Or, well, works as designed.

nikkilabrum’s picture

Status: Active » Closed (works as designed)

@seaneffel thank you so much for you simple explanation! It really helped me out :)

jrbeeman’s picture

This appears to have changed since February's post by seaneffel. To do this in latest OG as of this writing (7.x-2.3), you need the following relationships:

1. OG membership: OG membership from Node
2. (OG membership from node) OG membership: Group Node from OG membership

So, the 2nd relationship depends on the first. Once these relationships are setup, you can add fields or filters to your view based on the 2nd relationship (e.g. show the group title).

legovaer’s picture

I managed to get this done with only one relationship.

https://drupal.org/node/1942282

seaneffel’s picture

Numbers 75 and 79 provide different results to solve different use cases.

#79 gets a gid based on the currently loaded node. This is good for showing nodes from a group on the current group page.

#75 gets a gid of any node regardless of the currently loaded node. This is good for showing nodes and their parent groups on, say, a user profile or a dashboard page.

dafeder’s picture

Priority: Major » Normal
Status: Closed (works as designed) » Active

Can someone explain why og_group_ref doesn't work like any other entity reference field? Looking at how the entities and database tables are structured it seems like there's no need to join the {og_membership} table; the relationship is right there directly in {field_data_og_group_ref}. If there's something about the OG data model that makes this impossible that I'm not getting, wierd, but ok, but otherwise is this just a question of a bug in the code that can be patched?

gettysburger’s picture

I am trying to use #75 to create a view of group content with a field that shows the group name, outside of a group context. The problem I am having is with "2. Add relationship "OG membership: OG group gid" and set it to depend on the prior relationship (see #1)." I have no "OG Group gid" in my list of available relationships. Any thoughts? Thanks.

Update: actually I got it working through a relationship through the node author. Go figure. I will check back when I figure out how that worked...

mazzy27’s picture

How does this work in 7.x-2.7?

garchris’s picture

Issue summary: View changes

Has anyone been able to get this to work in 7.x-2.7?

I am able to display related content on the group page, but I am unable to get all content associated with this page, eg members' blog posts, to show at pages/%group/blog.

I am able to get all blogs that are group content, but as soon as I add contextual filter, I get "There is no content in this group". I have tried many of the solutions in this post but none seems to work for 7.x-2.7 version.

I've:

  1. Added relationship: OG membership: Node from OG membership
  2. Added relationship: OG membership: OG membership from Node using the above relationship.
  3. Added contextual filter: OG membership: Og membership ID using relationship (node from OG membership) and selected to provide default value based on "current OG from context".
  4. Added relationship Node from OG membership to Title and other fields.

I have spent several hours trying to get this to work. Any help is greatly appreciated.

pbcelery’s picture

These aren't working for me.
It's frustrating not being able to show related pages when on a group-content page. E.g. I'm on a group, view a subpage, want to see other subpages. Can someone post a view export? I'll recommend OR Extras add this as a canned view.

diddism’s picture

For 2.7.

The panel needs the relationship. This can be added on the contexts-page of the panel. The relation I added was: Node from Node (on Node: Groups audience [og_group_ref])

When this is added it can be chosen instead of "This node" when Views panes are added to a page-layout.

This works with the default OG Content-view with the relation OG membership: Group Node from OG membership added to it. (on groups without content this gives No content in this group however.)

slcmayor’s picture

I've found another way to achieve this. Install Corresponding Entity Reference (CER), create an ER field on the parent content type, create a CER preset where the child ER field is left and the parent ER field is right, do a CER bulk update of nodes, and you'll be able to see your child nodes in a view with the Content: Title field and a relationship to 'Content entity referenced from _child ER field_'. Hope this helps!

  • amitaibu committed 5e5ddef on 8.x-1.x
    Issue #1238186 by casey, tim.plunkett | Les Lim: Add views relationship...
joelpittet’s picture

Status: Active » Closed (outdated)

Drupal 7 reached end-of-life and the D7 version of Organic Groups is no longer being developed. To keep the issue queue focused on supported versions, we’re closing older D7 issues. If you still have questions about using Organic Groups on Drupal 7, feel free to ask. While we won’t fix D7 bugs anymore, we’re happy to offer guidance to help you move forward. You can do so by opening (or reopening) a D7 issue, or by reaching out in the #og channel on Drupal Slack.

If this issue is still relevant for Drupal 10+, please open a follow-up issue or merge request with proposed changes. Contributions are always welcome! 💙

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.