Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
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
Comment #1
amitaibuHi 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).
Comment #2
g089h515r806 CreditAttribution: g089h515r806 commentedDo 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.
Comment #3
g089h515r806 CreditAttribution: g089h515r806 commentedI 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.
Comment #4
amitaibuViews 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.
Comment #5
g089h515r806 CreditAttribution: g089h515r806 commentedthe 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.
Comment #6
g089h515r806 CreditAttribution: g089h515r806 commentedI have not test it with regular entity reference field, maybe it is a bug of entity reference.
Comment #7
dtarc CreditAttribution: dtarc commentedI'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?
Comment #8
dtarc CreditAttribution: dtarc commentedI discovered that it was very easy to use EntityFieldQuery to get group posts:
Thanks for making it easy. I'm getting much more stoked about OG7 after using the 2.x branch a bit.
Comment #9
aasarava CreditAttribution: aasarava commentedAmitai, 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.
Comment #10
amitaibu@aasarava, did you try with latest -dev?
Comment #11
aasarava CreditAttribution: aasarava commentedYes, with:
og: 7.x-2.0-alpha2+48-dev
entityreference: 7.x-1.0-rc1
Comment #12
amitaibuI'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.
Comment #13
aasarava CreditAttribution: aasarava commentedThank you! I have tested it and it seems to work.
Comment #15
Sinan Erdem CreditAttribution: Sinan Erdem commentedI 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
Comment #16
BrightBoldSame 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?Comment #17
BrightBoldUpdate:
[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.Comment #18
lahode CreditAttribution: lahode commentedHi,
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?
Comment #19
g089h515r806 CreditAttribution: g089h515r806 commentedTest 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.
Comment #20
g089h515r806 CreditAttribution: g089h515r806 commentedtry it with [site:og-context--node:nid] after i enable Organic groups context, it still soes not work.
Comment #21
g089h515r806 CreditAttribution: g089h515r806 commented[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.
Comment #22
a.milkovskyComment #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.
Comment #23
tyler.frankenstein CreditAttribution: tyler.frankenstein commentedThank 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:
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']