2013-10-01 35 views
0

drupal 6.我有這個hook_menu()。如何在drupal中調用模塊中的不同函數6

$items['graph'] = array(
    'title' => t('Sample Graphs'), 
    'page callback' => 'graph_content', 
    'type' => MENU_CALLBACK, 
    'access arguments' => array('access content'), 
); 

    $items['graph/line_graph'] = array(
    'title' => t('Line Graph'), 
    'page callback' => 'line_graph_content', 
    'type' => MENU_CALLBACK , 
    'access arguments' => array('access_content'), 
); 

我想轉到其他頁面的折線圖。當我去'?q = graph'時,它會調用graph_content函數。它正在工作,但是當我去'?q = graph/line_graph'時,同樣的函數會調用它。 'graph'和'line_graph'的輸出是相同的。他們在同一個模塊中誰能幫我解決這個問題?謝謝!!

+0

您需要使用hook_menu_alter –

回答

0

我在一個自定義模塊中測試了你的代碼,它爲我工作。我有兩個不同的輸出。測試它,讓我知道它是否適合你。

function mymodule_menu() { 
    $items['graph'] = array(
     'title' => t('Sample Graphs'), 
     'page callback' => 'graph_content', 
     'type' => MENU_CALLBACK, 
     'access arguments' => array('access content'), 
    ); 

    $items['graph/line_graph'] = array(
     'title' => t('Line Graph'), 
     'page callback' => 'line_graph_content', 
     'type' => MENU_CALLBACK, 
     'access arguments' => array('access_content'), 
    ); 
    return $items; 
} 

function graph_content(){ 
    return 'hello '. __FUNCTION__; 
} 

function line_graph_content(){ 
    return 'hello '. __FUNCTION__; 
} 
+0

謝謝!它工作正常。我試圖清除緩存,我的代碼現在可以正常工作。謝謝! – aiipee

相關問題