开发者

Have trouble creating an hello-world module in drupal 5

开发者 https://www.devze.com 2023-01-07 14:46 出处:网络
Here\'re the steps I did to create an mudule: create a directory groups under sites/all/modules in the above directory groups, create two files groups.module and groups.info

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?


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消