Closed (fixed)
Project:
Organic Groups
Version:
7.x-2.x-dev
Component:
og-context
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
11 Sep 2012 at 16:29 UTC
Updated:
10 Nov 2016 at 19:24 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
amitaibuNot on purpose, a patch would be great :)
Comment #2
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 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 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 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 commentedDid you find a permanent solution ?
Comment #10
jayaram commentedDid you find any other solution ?
Comment #11
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 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 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 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 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 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 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 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 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 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 commentedComment #22
ajayg commentedSince it is RTBC, what needs to happen to get this committed?
Comment #24
amitaibuMerged, thanks.