Custom Drupal 6 Module with multiple pages

53 views Asked by At

I am trying to write my first Drupal custom module (using drupal 6). I got the basic module working but I would like to add another page to the project. For example, right now my module's path looks like this: www.mysite.com/my_custom_module. I would like to add another page like this: www.mysite.com/my_custom_module/my_sub_page. I've tried adding a new .module and .info file but this does not work. I've also tried adding new items to the menu hook, like this:

my_custom_module.module:

function my_custom_module_menu(){
    $items  = array();
    $items['my_custom_module'] = array(
        'title' => "My Custom Module",
        'page callback' => "my_custom_module_info", 
        'access callback' => true,  
        'type' => MENU_NORMAL_ITEM, 
    );
    $items['my_custom_module/my_sub_page'] = array(
        'title' => "My Sub Page",
        'page callback' => "my_custom_module_sub_page_info", 
        'access callback' => true,  
        'type' => MENU_NORMAL_ITEM, 
    );
    return $items; 

}

function my_custom_module_info(){
    $result = 'My Page URL was hit';
    return $result;
}
 function my_custom_module_sub_page_info(){
    $result = 'My Sub Page URL was hit';
    return $result;
}

In this example, if I go to .../my_custom_module it works fine. But, if I go to .../my_custom_module/my_sub_page, it still load, and displays my_custom_module. When I debug with a break point in each function, only my_custom_module_info is hit. Not the sub page. What am I doing wrong? I this even the correct way to create multi pages in a module? Just an FYI, each of these pages will have different audiences. The first page is to allow a user to submit some form data. The second is to allow an elevated user view the data.

Thanks

jason

0

There are 0 answers