06. Installing, enabling and testing the module

Last modified: March 16, 2006 - 18:04

At this point, you can install your module and it'll work. Let's do that, and see where we need to improve the module.

To install the module, you'll need to copy your onthisdate.module file to the modules directory of your Drupal installation. The file must be installed in this directory or a subdirectory of the modules directory, and must have the .module name extension.

Log in as your site administrator, and navigate to the modules administration page to get an alphabetical list of modules. In the menus: administer » modules, or via URL:

    http://.../admin/modules or
    http://.../?q=admin/modules

When you scroll down, you'll see the onthisdate module listed with the description next to it.

Enable the module by selecting the checkbox and save your configuration.

Because the module is a blocks module, we'll need to also enable it in the blocks administration menu and specify a location for it to display. Node modules may or may not need further configuration depending on the module. Any module can have settings, which affect the functionality/display of a module. We'll discuss settings later. For now, navigate to the blocks administration page: admin/block or administer » blocks in the menus.

Enable the module by selecting the enabled checkbox for the 'On This Date' block and save your blocks. Be sure to adjust the location (left/right) if you are using a theme that limits where blocks are displayed.

Now, head to another page, say, select the modules menu. In some themes, the blocks are displayed after the page has rendered the content, and you won't see the change until you go to new page.

If you have content that was created a week ago, the block will display with links to the content. If you don't have content, you'll need to fake some data. You can do this by creating a blog, forum topic or book page, and adjust the "Authored on:" date to be a week ago.

Alternately, if your site has been around for a while, you may have a lot of content created on the day one week ago, and you'll see a large number of links in the block.

Installing a module with newer releases of drupal

mightypile - January 1, 2008 - 14:52

If you can't get your newly minted module to show up in your admin pages, you may be following along with the tutorial perfectly and building a module that will only work with 4.x builds of drupal. Your code is probably fine, but you may need to accompany that code with some meta- information, a header file, if you will.
In 4.x, if you put your mymodulename.module file in the modules directory, it was available for use.
In 5.x, a mymodulename.info file is required to accompany your mymodulename.module file.
In 6.x, it's required to have the mymodulename.info file and also to specify the compatibility of your module.
To make your module work in 6.x, include a file like follows:

name = mymodulename
description = A description of this module, perhaps, On This Day
core = 6.x
php = 5.1

To make it work in 5.x, include a similar file
name = mymodulename
description = A description of this module, perhaps, On This Day

Jump ahead to http://drupal.org/node/101009 for better tutorial information on 5.x.
to http://drupal.org/node/114774#info for new 6.x updates.

-Mike

 
 

Drupal is a registered trademark of Dries Buytaert.