这是我第一次使用Drupal 7,我写了一个回音"test"的测试模块,在菜单中路径是"test".
当我试图访问localhost/drupal/test或localhost/drupal/admin/test时,它无法找到它,我看到404或管理页面.
这里有什么问题?
这是代码,它不起作用
<?php
/* $Id$ */
/**
* @file
* Very simple DRUPAL module
*/
/**
* Implementation of hook_help().
*/
function hello_world_help($section) {
switch ($section) {
case 'admin/help#hello_world':
$output = '<p>Hello world help...</p>';
return $output;
case 'admin/modules#description':
return 'Hello world module description...';
}
}
/**
* Implementation of hook_menu().
*/
function hello_world_menu($may_cache) {
$items = array();
if ($may_cache) {
}
else {
$items[] = array(
'path' => 'hello', // drupal path example.com/?q=hello
'title' => 'Hello world page...', // page title
'callback' => 'hello_world_page', // callback function name
'access' => TRUE, // every user can look at generated page
'type' => MENU_CALLBACK // define type of menu item as callback
);
}
return $items;
}
/**
* Function which generate page (this generate any content - you need only your own code...)
*/
function hello_world_page() {
return '<p>Hello world!</p>';
}
?>
Run Code Online (Sandbox Code Playgroud)
sbr*_*tla 10
使用drupal_get_path()获取模块或主题的路径.如果你的模块名称是'mymodule',那么你只需调用下面的代码来获取路径.
drupal_get_path('module', 'mymodule');
Run Code Online (Sandbox Code Playgroud)
编辑
再次阅读你的问题让我意识到你要求你的模块的URL.你能否在你的模块的hook_menu()中发布你的代码?