field_data_og_group_ref table is empty, I have add some group content, but this the table of this field is empty.
I could not use it as a views contextually filter.
Is it by design?

Comments

amitaibu’s picture

Category: bug » support
Status: Active » Fixed

Hi g089h515r806!

Yes, the table is kept empty, as don't use the field storage (just the widget/ formatter). Instead we create an OG-membership entity. You can have a look at the provided default views, to see how to use OG membership in a view (i.e. as relationship).

g089h515r806’s picture

Status: Fixed » Active

Do not compatiable with pathauto module.

I use pathauto module, and set the path alias to:
company/[node:og_group_ref]/job/[node:nid]

I could not get [node:og_group_ref] in the alias path of a job.

g089h515r806’s picture

I try it with [node:og_group_ref:nid], I get a error,
Then i try it with [node:og-group-ref:nid], It still not works correctly.

Maybe we could save a copy of the data to field_data_og_group_ref table, then it will works much better with views and pathauto.

amitaibu’s picture

Views works ok with the OG membership relationship, and we don't want to duplicate our data.
Regarding pathauto, it should be working, as in hook_load() we populate the field values on the fly.

  1. What error are you getting?
  2. Is it working ok, when you use a regular entity reference field?
g089h515r806’s picture

the result alias is "company/job/32"
My expectation is "company/22/job/32"

It does not work as my expectation.

This is my requirement:
company/22
company/22/job/32
company/22/discussion/35
company/22/event/41

company is a group which represent a company. job,discussion,event are group content type.

I think the reason is, when pathauto generate the value of "[node:og_group_ref]", it does not called hook_load() .
I am not sure.
It is very similar with that i could not use og_group_ref as contextually filter of views.

g089h515r806’s picture

I have not test it with regular entity reference field, maybe it is a bug of entity reference.

dtarc’s picture

I'm trying to get this to work with EntityFieldQuery but can't set fieldCondition()s on og_group_refs.

Is there a way to use EntityFieldQuery with OG 7.x-2.x?

dtarc’s picture

I discovered that it was very easy to use EntityFieldQuery to get group posts:

    $query = new EntityFieldQuery();
    $query->entityCondition('entity_type', 'og_membership', '=')
      ->propertyCondition('entity_type', 'node', '=')
      ->propertyCondition('field_name', 'og_group_ref', '=')
      ->propertyCondition('gid', $gid, '=');

Thanks for making it easy. I'm getting much more stoked about OG7 after using the 2.x branch a bit.

aasarava’s picture

Amitai, I'm having the same problem as g089 reports with the tokens, in particular [node:og-group-ref:nid]. It works fine when using regular entity reference. When using groups reference, the token is not populated.

amitaibu’s picture

@aasarava, did you try with latest -dev?

aasarava’s picture

Yes, with:

og: 7.x-2.0-alpha2+48-dev
entityreference: 7.x-1.0-rc1

amitaibu’s picture

Version: 7.x-2.0-alpha1 » 7.x-2.x-dev
Status: Active » Fixed

I've committed a fix, that should properly populate the group-audience field values, so pathauto should work.

og_field_attach_insert/ update() are now making sure the entity has the field values updated.

aasarava’s picture

Thank you! I have tested it and it seems to work.

Status: Fixed » Closed (fixed)

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

Sinan Erdem’s picture

Status: Closed (fixed) » Active

I am using the latest version of og (2.x-dev, 2012-May-01). I use this form in pathauto pattern settings:

group/[node:og_group_ref]/[node:title]

but, instead of printing this as alias:
group/my_group/post_title

it only prints:
group/post-title

brightbold’s picture

Same problem here with rc3. I want the following pattern:

group/group ID/group content type/node ID

but I can't find the token for the group ID. It seems like [node:og-node1:nid] should work (this site is upgraded from 7.1, so instead of og_group_ref I have a different field for each content type; og-node1, og-node2, etc.) but Pathauto throws an "invalid token" error.

I think I could use [site:og-context-node] for newly created content, but this doesn't work for updating URLs with VBO, which I need to do. Any ideas?

brightbold’s picture

Update: [site:og-context-node:nid] works (the token I suggested above gives you the group title, not the ID), but of course not through VBO.

lahode’s picture

Hi,

I'm using OG for 40 different sites having 20'000 users in common. And with all that I must manage the userrights hierarchically for around 1000 departements. OG seems perfect to fit that need, however........

I created a shared database where I put the user table, profile2, an custom entity used for the OG group "departement", but as OG is not only used for the "department rights", I cannot put og_membership table into my shared database.

I thought I could just create a field in OG UI (/admin/config/group/fields) and assign it to my entity and then transfer the "field_data_xxx" table in my shared database, but the way everything is done (all infos into the same og_membership table) makes things complicate.

Have you a solution? Is there no way not to use og_membership but an entity_ref field or indicating somewhere that if the group_type is "departement", then OG should seek the information in "og_membership_departement" table?

g089h515r806’s picture

Test again with:
group/[node:og-group-ref:1:nid]/post/[node:nid]
it still does not work, [node:og-group-ref:1:nid] is empty.

g089h515r806’s picture

try it with [site:og-context--node:nid] after i enable Organic groups context, it still soes not work.

g089h515r806’s picture

[site:og-context--node:nid] does not work on pathauto's bulk update. it works on goup post's edit page.
[node:og-group-ref:1:nid] does not work on both case.

a.milkovsky’s picture

Issue summary: View changes

Comment #1 describes why the table is empty. It makes sense in most of cases.
But in this case the revision functionality is dropped.
When the field functionality is not used it's not possible to use revisions of the og_group_ref field.
For example:
When the entity with og_group_ref field needs moderation for change, it's not possible to change OG at all.

tyler.frankenstein’s picture

Thank you @a.milkovsky for pointing out the non-existant revision data for og_group_ref data. After all these years I'm surprised I never noticed this data isn't traditional field data with revision records.

Here's a way to hold onto the original og_group_ref value so that it is available later on for comparison:

/**
 *  Implements hook_node_presave().
 */
function example_node_presave($node) {
  if ($node->type != 'my_content_type') { return; }

  $language = $node->language;

  // Set aside the page's group id so we can watch for a change to a page's
  // group later.
  if (!empty($node->og_group_ref)) {
    $node->example_og_group_ref = array(
      'presave_target_id' => $node->original->og_group_ref[$language][0]['target_id']
    );
  }

}

Normally one should be able to programmatically access the $node->original values, but in case you're using a background process or shutdown function, you can grab the value from original and set it aside on the $node object for later, because the original value will get lost.

Later, access the value using $node->example_og_group_ref['presave_target_id']

  • 02bd099 committed on 8.x-1.x
    Issue #1456356 reported by g089h515r806, aasarava : Make sure to load...
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.