在 drupal 5 中创建 hello-world 模块时遇到问题
以下是我创建 mudule 的步骤:
groups
中的sites/all/modules
下创建一个目录- 在上述目录
groups
,创建两个文件groups.module
和groups.info
groups.info
的内容:
; $Id: groups.info,v 1.3 2006/11/21 20:55:36 dries Exp $
name = groups
description = Test Groups Listings.
package = "test groups"
version = "5.10"
project = "ed_groups"
datestamp = "1218672307"
groups.module
的内容:
<?php
function groups_menu($may_cache)
{
$items = array();
$items[] = array(
'path' => 'test_menu',
'type' => MENU_CALLBACK,
'callback' => 'groups_list',
'title' => t('All Group Listing')
);
}
function groups_list()
{
return 'helloworld';
}
我在访问 site.com/test_menu
时出现了 oops(404) 页面,
您能发现上面的问题吗?
Here're the steps I did to create an mudule:
- create a directory
groups
undersites/all/modules
- in the above directory
groups
, create two filesgroups.module
andgroups.info
The content of groups.info
:
; $Id: groups.info,v 1.3 2006/11/21 20:55:36 dries Exp $
name = groups
description = Test Groups Listings.
package = "test groups"
version = "5.10"
project = "ed_groups"
datestamp = "1218672307"
The content of groups.module
:
<?php
function groups_menu($may_cache)
{
$items = array();
$items[] = array(
'path' => 'test_menu',
'type' => MENU_CALLBACK,
'callback' => 'groups_list',
'title' => t('All Group Listing')
);
}
function groups_list()
{
return 'helloworld';
}
I got an oops(404) page when visiting site.com/test_menu
Can you spot what's wrong above?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
看来您的问题是您没有在
hook_menu
中返回 $items。应该是:
执行此操作后请记住清除缓存,因为 Drupal 会缓存菜单系统。
It looks like your problem is that you don't return $items in your
hook_menu
.It should be:
Remember to clear the cache after you do this, as Drupal caches the menu system.