Drupal 7 example module, page not found, why?

后端 未结 3 639
甜味超标
甜味超标 2021-01-26 18:09

I wrote a simple test module example, 2 files, test.module, test.info, and enabled them in drupal 7 modules.

I cleared all the cache, and still when i\'m trying to go to

3条回答
  •  情深已故
    2021-01-26 18:43

    You have posted almost the same question once and twice before. Why don't you update the original one instead of posting new ones?

    • The hook_menu() does not have the $may_cache argument in Drupal 7. You should remove it. However, it should not solve your problem as it is unset and false. Thus, the $items should still be populated.

    • It is correct, as jprofitt says, that you should change 'callback' to 'page callback'.

    • There is no such thing as 'access', but there is 'access callback' and 'access arguments'. You are most likely looking for 'access callback'. However, you can't just set it to 'true'. It expects a function name which returns either 'true' or 'false'. It defaults to 'user_access', so you should just leave it that way. However, you might want to set 'access arguments' to something like 'access content'.

    Does the following piece of code work better?

    function test_world_menu() {
    
      $items = array();
    
      $items['hello'] = array(
        'title' => 'Hello World!', 
        'page callback' => 'test_world_page', 
        'access arguments' => array('access content'), 
        'type' => MENU_CALLBACK 
        );
    
      return $items;
    }
    

    It seems that you haven't really had a look at the documentation. I might be wrong. However, the documentation at api.drupal.org is always a good start to look when you want to learn the basics of how something work.

提交回复
热议问题