我的模块在Drupal7中的路径是什么?
这是我第一次使用Drupal7,我编写了一个响应“test”的测试模块,菜单中的路径是“test” 当我试图访问localhost/drupal/test或localhost/drupal/admin/test时,它找不到它,我看到404或admin页面 这里有什么问题我的模块在Drupal7中的路径是什么?,drupal,Drupal,这是我第一次使用Drupal7,我编写了一个响应“test”的测试模块,菜单中的路径是“test” 当我试图访问localhost/drupal/test或localhost/drupal/admin/test时,它找不到它,我看到404或admin页面 这里有什么问题 这是代码,它不起作用 <?php /* $Id$ */ /** * @file * Very simple DRUPAL module */ /** * Implementation of hook_help().
这是代码,它不起作用
<?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>';
}
?>
用于获取模块或主题的路径。如果您的模块名为“mymodule”,则只需调用下面的代码片段即可获得路径
drupal_get_path('module', 'mymodule');
编辑
再次阅读你的问题让我意识到你在询问你模块的URL。你能在模块的hook_menu()中发布你的代码吗?如果我理解正确
hook_menu()
,其中创建了一个菜单路径测试(比如$item['test']
),并编写了一个页面回调函数如果是这种情况,您只需清除缓存即可。Drupal需要注册菜单项。在编写任何菜单钩子实现之后,您应该清除缓存的数据,然后重试。这可能会对您有所帮助:由于文章的标题,我在这里得到的可能是重复的,尽管这不是OP想要的,但它回答了我的问题:)