2014-09-01 4 views
0

drupal 설치시 domain.com/content/travel과 같은 URL이 있습니다. menu_get_active_trail 만 "노드/4"URL을 제공으로드루팔 (Drupal 7 - 메뉴 트레일을 얻는 방법?

$menuParent = menu_get_active_trail(); 
$path = $menuParent[1]['page_arguments'][0]->path; 
$pathArray = explode('/', $path); 
$menuParent = $pathArray[1]; 
$menuChild = trim($pathArray[3]); 

이 더 이상 D7에서 작동하지 않습니다 :

는 D6에서 내가 위에서 언급 한 흔적에서 "여행"을 추출하려면 다음 코드를 사용했다. D7에서 언급 한 URL을 어떻게 얻을 수 있습니까?

감사합니다.

+0

menu_get_active_trail 기능 페이지의 첫 번째 설명을 살펴보십시오. https://api.drupal.org/api/drupal/includes!menu.inc/function/menu_get_active_trail/7 – 2pha

답변

1

drupal_get_path_alias() 기능을 사용하여 활성 트레일의 경로 별칭을 가져올 수 있습니다.

$menuActive = menu_get_active_trail(); 

// Get the path alias from active trail 
$menuParent = drupal_get_path_alias($menuActive); 

$path = $menuParent[1]['page_arguments'][0]->path; 
$pathArray = explode('/', $path); 
$menuParent = $pathArray[1]; 
$menuChild = trim($pathArray[3]);