By attentat on
My hook_menu code is simple as can be and yet I can't get the page to load up. Am I missing something?
function my_module_menu() {
$items = array();
$items['mypath'] = array(
'title' => 'My Page',
'type' => MENU_CALLBACK,
'page callback' => 'my_module_page',
);
}
function my_module_page () {
return drupal_get_form('my_module_edit_form');
}
Comments
You need to return $items at
You need to return $items at the end of your hook_menu() over-ride.
Thanks!
Saints and Straddle be praised!
I'm having the same problem
with code that works in an clean installation of drupal, but does not work on my development site. I get "page not found" when I try to visit the URL (or when i type in q=front-os-detect)
any thoughts? I've uninstalled the module, cleared all caches, re-installed the module and nothing.
No type set
You need to set a type (i.e.
MENU_CALLBACK,MENU_NORMAL_ITEM, etc.) for your menu item.:(
adding 'type' => MENU_CALLBACK doesn't help.
Does your code look like
Does your code look like this?
yes.
this is, literally, the whole file.
I know this post is old but I
I know this post is old but I wanted to post in case someone else comes across this post.
If your code seems to be correct try going to the performance page and clearing the cache. This will fix the problem with page not found and access denied errors during testing (assuming your code is correct).
You're a genius, thank you
You're a genius, thank you very much...
Same problem...
I am having the same problem. However, clearing the cache does not work either. Am I missing something in my code? I also checked the database contents (menu_links and menu_router). Even after disabling and re-enabling the module, the links won't show up. Even navigating to "admin/build/modules" does not generate the items.
The module will eventually contain "sub-modules". Hence, hook_info looks like this. Has this anything to do with it? I tried some permutations with the naming of hook_menu, but may have overlooked something.
bump
bump
Since this has been dug up
Since this has been dug up anyway:
You have to set the type to MENU_NORMAL_ITEM for it to generate a link in the menu structure.
As someone else said, "Since
As someone else said, "Since this has been dug up anyway" ...
Your function names look fishy. If your module is called "minfo_nodes" then the function should be called "minfo_nodes_menu". Also make sure to clear the cache after making changes.
Thanks
Thanks to DonCoryon. I faced the same problem about hook_menu but after clearing cache the problem is solved.
Thank you once again.......=)
Teju
New installs D7
Also make sure you have clean URLs enabled.
You could have a perfectly coded hook_menu implementation but if you try and go to 'my-site.com/path' with clearn URLs disabled you will get a "Page not found" error.
Another reason could be...
...that you have a view (which is a page) that uses the same URL as you're defining as a key in the $items array.
I had this problem, using Drupal 7, despite the hook_menu() function being correct and having clean URLs functioning properly.
Turns out a view existed already which was using that URL. Unfortunately, there was no error message reporting this conflict, and neither the view nor the hook_menu() implementation overrode each other, and I just got a 404 until I deleted the view.
Had the same problem, but,
Had the same problem, but it was unrelated to hook_menu.
I checked the source and it was perfect.
After a while I decided to try clearing the cache using Drush only to get a message that CC had a problem with a second database and did not give any error messages when using the GUI.
Try Drush