0
votes

Good Day,

I am doing a hook_form_alter and followed a tutorial where you create a directory in your /sites/all/modules directory and place the module.info and mymodule.module files within. I've called that directory mymodule so the path will be /sites/all/modules/mymodule.

The problem I'm having is trying to enable the module. It does not show up in the list of Modules when I check. It's clearly in my directory.

My module (my_module.module) looks like this and is going to be used to modify the form where you add the product (basically taking out the SKU, list price and commission):

<?php
// $Id$

/**
* @file
* Module to hold my customizations to Ubercart
*/

/**
* Implementation of hook_form_alter()
*/
function my_module_form_alter($form_id, &$form) {
  if ($form_id == 'product_node_form') {
    $form['base']['model']['#required'] = FALSE;
    $form['base']['prices']['list_price']['#required'] = FALSE;
    $form['base']['prices']['cost']['#required'] = FALSE;
    $form['base']['prices']['sell_price']['#required'] = FALSE;
    $form['base']['prices']['shippable']['#required'] = FALSE;
  }
}

And the info file, my_module.info, looks like this:

; $Id$
name = My module
description = My customizations to Ubercart
package = Custom
core = 7.x

Why would it not show up in the modules list and how do I make Drupal see the module so I can enable it? I don't have a category called Custom and nothing is showing up.

So far, i've gone into my php.ini file and put in safe_mode=off to see if that would help (because someone said this sometimes causes Drupal to ignore new modules for some reason) but that didn't help.

I created both files on the server so I don't think there would be any issues with something like linefeeds (I use GoDaddy's FTP File Manager and it comes with an editor.)

What could the problem be because I'm stumped?

Thanks for looking.

2
I've also tried taking the 'package' line out because I saw an example where it's not used (on the Drupal module tutorial page.) Still not showing up in the list. How could this be happening? - Shawn

2 Answers

0
votes

Make sure to name the .info and .module files with the same name.

E.g. mymodule.info and mymodule.module.

Note that, the name should be alpha-numeric (underscore is allowed) and starts with a letter.

In your hook implementation, replace the word hook with your module's name

function mymodule_form_alter($form, &$form_state, $form_id)
{
    // code goes here...
}
-1
votes

I discovered something that works. After reading about people having issues with linefeeds and not knowing if this was creating the problem, I decided to try something.

I went to a module directory and found a .info file. In my case, I went to a directory that had Commerce in it and copied the Commerce.info file to my custom module's directory.

Then, what I did was take out the stuff that Drupal added after it installed the Commerce module (you can do the same for whatever .info file you copy from) and modified the information at the start, removing any dependency lines or anything that doesn't matter. In other words, make it like the .info file you are trying to use but DON'T COPY from the .info you've been trying to enable!

Save it this file (in my case, it's still commerce.info.)

Now delete the .info file you were trying to enable originally.

Rename the new .info file to the name you wanted (commerce.info => mymodule.info.)

Go to your Modules page and refresh it.

Voila...there it is. Enable and save configuration.