How To Easily Make A Quick Module In Drupal 7

10 years 6 months ago
How To Easily Make A Quick Module In Drupal 7

I still dont completely understand hooks and all that.  This is maily to have a library of functions you can use across themes.  I used to put everything in template.php, cause ya know, it works.  However then when i was in my admin theme i would get errors of "undefined functions."

this is not a new post, of course, but alot of the ones i see when i search are complex.  Once again, hooks are too much for me atm.  This is meant to be a simple explaination, and a quick reference for me.

1. Create a Folder called SOMETHING inside /sites/all/modules

2. Create SOMETHING.info inside that folder.  It is a simple text file with this code:

name = SOMETHING
description = All the custom functions for SOMETHING
core = 7.x

3. Create SOMETHING.module inside the folder.  This is where you will put your php code.

function myfunction(){
   echo 'Hello world!'
}

Then go to your modules page, find the SOMETHING module and enable it.  You will now be able to use any functions in your .module page anywhere on your site.  Its so much easier than I thought it was.

< Return to Code Listing

How To Easily Make A Quick Module In Drupal 7