简体   繁体   中英

How to call different function inside a module in drupal 6

in drupal 6. i have this hook_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'),
  );

i want to go to another page for the line graph. When i go to '?q=graph' it calls the graph_content function. it is working but when I go to '?q=graph/line_graph', the same function call it. the output of 'graph' and 'line_graph' are the same. They are in the same module Who can help me with this issue? THANKS!!

I tested your code in a custom module and it working for me. I have two differents outputs. Test it and let me know if it working for you.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM