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.
I'm setting this as a support request, but it may just be by design (although I wouldn't recommend it).
It seems like the group context is only set when viewing a group node (node/%), but no where else (ie, node/%/group, /group/node/%/admin/people/*, etc, etc). I haven't yet tested if group context can be set via a View that takes an entity ID argument.
Is that done on purpose? It doesn't make sense to me.
Comment | File | Size | Author |
---|---|---|---|
#19 | og-context_only_set_on_primary_node_view_page-1781386-19.patch | 573 bytes | robertom |
#16 | prvek_node_tabs_export.txt | 6.86 KB | milos.kroulik |
Comments
Comment #1
amitaibuNot on purpose, a patch would be great :)
Comment #2
mstef CreditAttribution: mstef commentedI'm still learning the ropes of OG7.x-1.x, especially the og_context module. There's two active context detectors (URL and Node). URL only detects based on URL queries (ie, ?gids[]=), and Node seems to only look for node/% being the active path (which explains why the context is lost on those other pages).
I'm not sure if we should modify the node handler callback (og_context_handler_node()), or make a new one, so that paths like /group/%entity/%etid/* can grab the context).
What do you think?
Comment #3
amitaibuWe can extend the node view existing context-handler to work also on group/node/%
Note that 1.x is bug fix only branch...
Comment #4
mstef CreditAttribution: mstef commentedThe "node" part of that is an entity-type argument though, right?
Wouldn't it make sense to have a general context handler that can see if *any* page path contains both an entity-type and entity-id, then see if that is a group, then we have our context?
Comment #5
amitaibuHow would you do it?
Comment #6
mstef CreditAttribution: mstef commentedHere's something I just wrote to mess with..obviously far from perfect... just thinking
Comment #7
amitaibuRemember, it should be for 2.x -- you don't have the group entity there anymore..
Comment #8
mstef CreditAttribution: mstef commentedI'm sort of stuck on og1.x right now. I assume the same issue exists for 2.x though?
That bit I wrote obviously needs work, since we can't blindly assume the first number in the URL is the entity_id -- and I guess you could say the same about finding the entity_type...
Comment #9
jayaram CreditAttribution: jayaram commentedDid you find a permanent solution ?
Comment #10
jayaram CreditAttribution: jayaram commentedDid you find any other solution ?
Comment #11
mstef CreditAttribution: mstef commentedI definitely didn't find anything permanent or wonderful, but I have a workaround in place. It was needed for og_features.
Check out og_features_get_group_context(): http://drupalcode.org/project/og_features.git/blob/refs/heads/7.x-1.x:/o... (warning; it's a little scary)
Aside from this issue, it also is a workaround for #1781218: Calling og_context() in a menu access callback crashes system.
Comment #12
jayaram CreditAttribution: jayaram commentedThe other solution to this would be to use page manager to create pages or menu tabs. I was able to get the group context on all the tabs this way.
Comment #13
MarcM CreditAttribution: MarcM commentedI think i have this same issue with OG 7.2: http://drupal.org/node/1843182
jayaram, I'm quite curious to know how you could get the context everywhere.
Comment #14
jayaram CreditAttribution: jayaram commented@MArcM,
If you creating a new tab on the Group page lets say its " Group Content", Instead of using views, Use page manager and add a new custom page(node/%node/content). make sure your page has the group context(OG group from node) relationship.
Comment #15
rv0 CreditAttribution: rv0 commentedAnyone found an elegant solution yet?
Currently for Views tabs I'm using custom code in hook_views_pre_view
There I give an og_context.
Works fine, but isn't elegant ;)
A setting on a the view to catch context would be nice, but where in the UI does it belong?
Comment #16
milos.kroulik CreditAttribution: milos.kroulik commentedUnfortunately, solution in #15 doesn't work for me. Is there anything, that should be added to make it work?
I have added following code in custom module:
Export of my view is enclosed. The result is, that same view with contextual filter (default value "Current OG Group from context") displays on node but not in tab defined in view.
Comment #17
tanius CreditAttribution: tanius commentedAnswering #15:
That setting is already there (but does not work, which is why I set this to "bug report"). Namely, for a contextual filter one can already set "When the filter value is NOT available: Provide default value: Current OG group from context". Currently this has no effect.
Also I set it to version 7.x-2.x-dev to bring it up for current development (a fix may be backported to 7.x-1.x).
Comment #18
rv0 CreditAttribution: rv0 commented@tanius: that setting is for getting the group from context, not for setting the context
the code in #15 is to set the context
Comment #19
robertom CreditAttribution: robertom at bmeme commentedHi, sorry for my bad english.
I have same problem when I create a views page with path node/%/....
for solve that I have added the patch attached
Comment #20
indigoxela CreditAttribution: indigoxela commentedJust tested patch #19.
On:
drupal 7.50
organic groups 7.x-2.9
I can confirm that the patch solves the problem.
Block visibility from og context on views pages work correctly again.
No side effects or problems discovered.
Would be nice to get this into the next release.
Comment #21
indigoxela CreditAttribution: indigoxela commentedComment #22
ajayg CreditAttribution: ajayg as a volunteer commentedSince it is RTBC, what needs to happen to get this committed?
Comment #24
amitaibuMerged, thanks.