I'm reading a book, Drupal 7 Module Development, and I'm hitting some very weird outputs.

I created a folder:


Inside this folder I created two files.



name = First
description = A first module
package = Drupal 7 Development
core = 7.x
files[] = first.module

;dependencies[] = autoload
;php = 5.2



// $Id$

 * @file
 * A module exmplifying Drupal coding practices and API's.
 * This module provides a block that lists all of the 
 * installed modules. It illustrates coding standards,
 * practices, and API use for Drupal 7.

 * Implements hook_help().
function first_help($path, $arg) {
    if ($path == 'admin/help#first') {
        return t('A demonstration module.');

But when I activate the module, I get the contents of the first.module file spashed across the top of my page? Can someone advise me on what I am doing wrong?

This is my very first module for Drupal.


2 Answers 2


You just have to follow the steps which I am writing below to create a module.

  • Go to folder SITES/ALL/MODULES
  • Create a folder for module, suppose mymodule
  • Inside that folder create a file name mymodule.info
  • Write these lines in there:

    name = My Custom Module

    core = 7.x

    description = Custom module created for testing.

  • Create another file named mymodule.module

  • Just open the PHP tag like <?php and save the created .module file

  • Visit your module list & you will find this module in the list over there. If not then clear the cache for once.

Problem with your process which I saw is with the path which you followed for creating the folder for your module which SITES/DEFAULT/MODULES, which is not correct.

  • I got that path from the book. It says, mysite.com/modules is reserved for core modules, no touch... mysite.com/sites/all/modules is for Add-on modules and is not the recommended place to put custom modules unless you are running a multi-site configuration and the custom module needs to be accessible on all sites...and that mysite.com/sites/default/modules is where you put custom modules per Drupal best practices... so... now I'm confused. Jun 14, 2013 at 19:23
  • Though I haven't read the book, but usually we follow the path sites/all/module path to put all the contributed & custom module. For keeping the contributed module & custom seperate from each other you can create two folder inside sites/all/modules e.g. sites/all/modules/contrib & sites/all/modules/custom. You can put modules accordingly & it will work...
    – RajeevK
    Jun 14, 2013 at 19:29
  • After moving it I no longer get that issues with the contents of first.module displaying on screen... so thank you! Jun 14, 2013 at 19:47

Is that the exact code that is in the book? My copy is at the office.

It looks like you have simple PHP error. The opening line should read


and not


Make that change, and things should start working again.

  • it didn't. It still doesn't display a help link in the module screen, it still dumps the contents of the first.module file at the top of the screen in unformatted text... I'm so confused. Jun 14, 2013 at 17:34
  • Ok... the text across the screen is actually the bad text. Almost like it isn't seeing my updated file. It's shows the $php instead of the ?php... Jun 14, 2013 at 17:37
  • Go to /admin/config/development/performance and clear your caches.
    – Triskelion
    Jun 14, 2013 at 17:54
  • I've cleared cache and it still pops up. I have now deleted the entire first folder and will be trying again... I'll update as needed. Jun 14, 2013 at 17:56
  • Don't you think it's the path problem which he has followed to create folder for module ?
    – RajeevK
    Jun 14, 2013 at 18:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.