views:

34

answers:

1

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?

+2  A: 

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.

googletorp
Does **drupal** require some kind of configuration to enable before a newly created module can take affect?
You need to enable the module, before it will do anything.
googletorp