the info file is right,the following is my module file code. when i access the http://localhost/drupal/mymenu why it can't work.
<?php
function mymenu(){
$item = array();
$item['mymenu'] = array(
'description'=>'test1',
'page callback'=>'mymenu_test',
'access arguments' => array('access mymenu'),
'type'=>MENU_CALLBACK,
);
return $item;
}
function mymenu_perm(){
return array('access mymenu');
}
function mymenu_test() {
$output = 'hello world';
return $output;
}
i have gave the 'access mymenu' permission to the anonymous.
It should be
function mymenu_menu() {
...
}
You don't need the $item = array(); there also.
whenever you see a api function with hook_something, you have to replace the 'hook' part with the name of your module
in this case it's indeed mymenu_menu
Try the following: use function name as modulename_menu
and use 'access arguments' => array('access content')
.
<?php
function test_menu(){
$item = array();
$item['mymenu'] = array(
'description'=>'test1',
'page callback'=>'mymenu_test',
'access arguments' => array('access content'),
'type'=>MENU_CALLBACK,
);
return $item;
}
function mymenu_test() {
$output = 'hello world';
return $output;
}
you need to flush menu cache(at least two times in drupal 7) after adding menu item with hook_menu.