Search code examples
functiondrupalmoduledrupal-moduleshook-menu

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!!


Solution

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