2014-02-13 4 views
0

Drupal 7에서 그룹 컨텍스트를 어떻게 설정합니까? Drupal 그룹 컨텍스트 설정 방법

나는 og_context API를이 발견 :

**> 7 og_context.module의 og_context ($ group_type = '노드', $ 그룹 = NULL)

받거나 메뉴를 사용하여 그룹 컨텍스트를 설정 체계.

매개 변수

$ group_type : 그룹 유형으로 얻을 컨텍스트. 기본값은 "노드"입니다.

$ 그룹 : 선택; 컨텍스트로서 설정하는 그룹 엔티티입니다.

반환 값

어떤 상황이 발견 된 경우 그룹 유형 및 그룹 ID 또는 FALSE로 키가

배열입니다. ** 내가 입력하는 방법의 예를 발견하지 않았습니다

그러나는 " 그룹 실체 ". 나는 단지 사용하고자하는 그룹 노드 ID를 알고있다 (예를 들어, "40").

아무도 도와 줄 수 있습니까? 감사!

+0

근무를 : https://drupal.org/comment/8179187#comment-8179187 – user1866032

답변

0

이 내가 여기 해결책을 발견 나 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; 
}