如何设置Drupal组环境

问题描述:

如何在Drupal 7中设置组环境?如何设置Drupal组环境

我发现这个在og_context API:

**> 7 og_context.module og_context($ group_type = '节点',$组= NULL)

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

参数

$ group_type:上下文由组类型来获得。默认为“节点”。

$ group:Optional;要设置为上下文的组实体。

返回值

Array由组类型和组ID,或FALSE键控如果没有上下文被 找到。**

但是我还没有发现的如何输入任何的例子“的团体实体“。我只知道我想使用的组节点ID(例如,“40”)。

任何人都可以帮助我吗?谢谢!

+0

我发现这里的解决方案: https://drupal.org/comment/8179187#comment-8179187 – user1866032

我发现这里的解决方案:https://drupal.org/comment/8179187#comment-8179187

假设ARG(1)该群节点ID:

$node = node_load(arg(1)); 
og_context('node', $node); // Set og context 

这为我工作http://cgit.drupalcode.org/og_extras/tree/og_extras.module?h=7.x-1.x#n147

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; 
}