Drupal 7 如何设置Drupal组上下文

Drupal 7 如何设置Drupal组上下文,drupal-7,organic-groups,Drupal 7,Organic Groups,如何在Drupal7中设置组上下文 我在og_上下文api中发现: **>7 og_context.module og_context($group_type='node',$group=NULL) 使用菜单系统获取或设置组上下文 参数 $group\U type:按组类型获取的上下文。默认为“节点” $group:可选;要设置为上下文的组实体 返回值 由组类型和组ID键入的数组,如果未创建上下文,则为FALSE 找到了** 但我没有发现任何关于如何进入“集团实体”的例子。我只知道要使用的组节点

如何在Drupal7中设置组上下文

我在og_上下文api中发现:

**>7 og_context.module og_context($group_type='node',$group=NULL)

使用菜单系统获取或设置组上下文

参数

$group\U type:按组类型获取的上下文。默认为“节点”

$group:可选;要设置为上下文的组实体

返回值

由组类型和组ID键入的数组,如果未创建上下文,则为FALSE 找到了**

但我没有发现任何关于如何进入“集团实体”的例子。我只知道要使用的组节点ID(例如,“40”)


有人能帮我吗?谢谢

我在这里找到了解决方案:

假设arg(1)是组节点id:

$node = node_load(arg(1));
og_context('node', $node); // Set og context
这对我有用

我在这里找到了解决方案:
function mymodulename_og_context_negotiation_info() {
  $providers = array();
  $providers['mymodulename'] = array(
    'name' => t('mymodulename url'),
    'description' => t("Select group context for any url that starts with 'group/%'. Make sure that all views and custom pages use paths that start with this value in order for the context to be recognized when viewing those pages, and that nothing that is not a group uses that path."),
    'callback' => 'mymodulename_context_handler_url',
  );
  return $providers;
}

/**
 * Context handler; Get groups from URL.
 */
function mymodulename_context_handler_url() {
  $context = array();
  if (arg(0) == 'group' && is_numeric(arg(1))) {
    $context = array('node' => array(arg(1)));
  }
  return $context;
}