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.
When I set the context detection for group URL to true I got an error on og_get_group function in og_extras_context_handler_url.
I tried to find a way around and what I found is the following modification :
/**
* Context handler; Get groups from URL.
*/
function og_extras_context_handler_url() {
$context = array();
if (arg(0) == 'group' && is_numeric(arg(1))) {
$context = array('node'=>array(arg(1)));
/*
$group = og_get_group('group', arg(1));
if (!empty($group) && !empty($group->nid)) {
$context = array($group->nid);
}
*/
}
return $context;
}
Now it works. I don`t really know if it`s a bug and if it`s the best way to correct it.
What do you think?
Comment | File | Size | Author |
---|---|---|---|
#3 | og_extra.module-issue-1703054.patch | 717 bytes | wadmiraal |
Comments
Comment #1
Thithi32 CreditAttribution: Thithi32 commentedComment #2
BrightBold@Thithi32 — Thanks! You're a lifesaver. I also was getting the error
Fatal error: Call to undefined function og_get_group() in /mysite/sites/all/modules/og_extras/og_extras.module on line 145
when visiting a page where context detection was required. I had poked around in the code looking for the source of theog_get_group()
function and couldn't find it anywhere in OG Extras, OG core, or OG Context, so I don't know if it has been removed or if I was just looking in the wrong place. At any rate, your modification solves the problem.Comment #3
wadmiraal CreditAttribution: wadmiraal commentedError is still on dev as well.
The following patch corrects the problem by using the updated OG API. Only use the patch if you're using OG 2 or higher. Also, note this patch only applies to node groups (which is what you would use in 99% of cases anyway).
@maintainers
You should consider creating a 7.x-2.x branch, which would follow the OG core upgrades. This patch could then be applied to that branch. Applying it to your current branch would be a bad idea, as it would break backward compatibility.
Comment #4
BrightBoldOG Extras module only works with OG 7.x-2.x, so this patch could be committed to the master branch.
Comment #5
joshuautley CreditAttribution: joshuautley commentedIt could but hasn't. What happened? Any progress?
Comment #6
manasiv CreditAttribution: manasiv as a volunteer commentedThe patch in #1 works with og extras 7.x-1.2. Thank you!