I have something like this defined:

function verimail_menu($may_cache)
{
    $items = array();
    
    if ( $may_cache )
    {        
        $items[] = array(

            'path'          => 'admin/verimail',

            'title'         => t('VeriMail settings'),

            'description'   => t('Adjust VeriMail settings'),

            'callback'      => 'system_admin_menu_block_page',

            'access'        => user_access('administer VeriMail')

        );
        

        $items[] = array(

            'path'          => 'contact',

            'title'         => t('Email Contact'),

            'description'   => t('Provides an interface for users to submit an email contact.'),

            'callback'      => 'verimail_contact_page',

            'access'        => user_access('send email through VeriMail'),
            'type'          => MENU_SUGGESTED_ITEM

        );


        $items[] = array(

            'path'          => 'contact/mailqueued',

            'title'         => t('Mail Queued'),

            'description'   => t('Alerts users mail is queued.'),

            'callback'      => 'verimail_contact_queued_page',

            'access'        => user_access('send email through VeriMail'),
            'type'          => MENU_SUGGESTED_ITEM

        );
    }
    
    return $items;
}

I can hit the admin page, and I can hit the "contact" page, but when I go to the contact/mailqueued page I get a page not found. Is this not the correct way to do this? As a work around I have ended up doing something like this:

function verimail_contact_page( $value1="Geoff" )
{

    switch ($value1) 
    {
        case 'mailqueued':
            $output  = t( '<p>Message queued for delivery.  You have been sent an email with additional instructions on how to complete the delivery of your message.  Please read that email and follow its instructions.</p>' );
            break;
        case 'verifymail':
            $output  = t( 'Attempting to verify your email.' );
            break;
        default:
            $thisUser = user_load(array('name' => $value1));

            

            if ( $thisUser )

            {

                $output  = t('Attempting to contact %s', array( '%s' => $thisUser->name ));
                
                $output .= drupal_get_form('verimail_contactform');

            }

            else

            {
                $output  = '<p>';

                $output .= t('Sorry, but it appears you are trying to contact a user that doesn\'t exist on the system.');
                $output .= '</p>';
            }
    }
    
    return $output;
}

That way when a user hits the /contact page, the function takes care of deciding where they were trying to go. But that doesn't seem right to me. Pardon what looks like some sloppy coding, but this is sort of a stub-in as part of a larger project for work.

Comments

TheGorf’s picture

Anyone?

TheGorf’s picture

Anyone?

j_ten_man’s picture

I am not sure as I have never used MENU_SUGGESTED_ITEM before. However, a quick search brought me to a thread that seemed to be the same problem you are having:
http://drupal.org/node/139853
Hope that it helps.

TheGorf’s picture

Thanks, I tried what that post suggested but it didn't make a difference. I also removed all the "type" to see if it makes any difference and it doesn't. So I am still stuck.

TheGorf’s picture

Ok I am an idiot. The hook_menu is only read once apparently when the module is installed/activated. Subsequent changes after that to the modulename.module file don't get loaded into the system. I must have read

http://api.drupal.org/api/function/hook_menu

a dozen times and glossed over "This hook is called rarely - for example when modules are enabled" everytime without realizing what it was telling me.

newdru’s picture

how you fixed this. can you be a little more clear?

TheGorf’s picture

Yep. when I made a change to the modulename_menu function I wasn't seeing any changes. Just like I described up above, adding additional pages to the verimail_menu wouldn't seem to do anything. If I went to the path that I defined I would get a Page Not Found.

What I releazed suddenly reading the documentation is that the function verimail_menu is basically only read once when you activate the module in the Admin -> Modules page. So to make changes I would have to deactivate the module then reactivate it. That causes Drupal to re-read the _menu function and build the new paths in it's list of paths.

j_ten_man’s picture

I believe that has to do with your if($may_cache) conditional. It caches those items so if you clear your cache it should update your menus. I may be confused though.