dongyongyu0789 2010-07-13 09:27
浏览 40
已采纳

在drupal 5中创建hello-world模块时遇到问题

Here're the steps I did to create an mudule:

  1. create a directory groups under sites/all/modules
  2. in the above directory groups, create two files groups.module and groups.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?

  • 写回答

1条回答 默认 最新

  • dtzh131555 2010-07-13 10:00
    关注

    It looks like your problem is that you don't return $items in your hook_menu.

    It should be:

    function groups_menu($may_cache) {
        $items = array();
        $items[] = array(
            'path' => 'test_menu',
            'type' => MENU_CALLBACK,
            'callback' => 'groups_list',
            'title' => t('All Group Listing')
        );
        return $items;
    }
    

    Remember to clear the cache after you do this, as Drupal caches the menu system.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 结构功能耦合指标计算
  • ¥20 visual studio中c语言用ODBC链接SQL SERVER
  • ¥50 AI大模型精调(百度千帆、飞浆)
  • ¥15 非科班怎么跑代码?如何导数据和调参
  • ¥15 福州市的全人群死因监测点死亡原因报表
  • ¥15 Altair EDEM中生成一个颗粒,并且各个方向没有初始速度
  • ¥15 系统2008r2 装机配置推荐一下
  • ¥15 悬赏Python-playwright部署在centos7上
  • ¥15 psoc creator软件有没有人能远程安装啊
  • ¥15 快速扫描算法求解Eikonal方程咨询