Organizing Drupal Modules
When setting up a new Drupal project it’s important to organize your code, especially when working with teams. In Drupal, most or your core code will be in the form of modules. We typically organize our modules into 3 folders:
/sites/all/modules/contrib/
/sites/all/modules/custom/
/sites/all/modules/dev/Modules go in the sites folder
First, it’s important to put any Drupal modules that are not in core into the sites/ directory. This will make any Drupal core upgrades much easier and since you shouldn’t be modifying any Drupal core files, all your coding will be in the sites/all/ folder.
Separate contributed, custom and development modules
You’ll also notice that we separate contributed modules (those found on Drupal.org), custom modules (written specifically for this project), and development modules (contrib modules not used in a production enviornment).
It is highly unlikely that you will ever modify a contributed module, so keeping custom modules in their own folder makes searching for code to edit much easier. If you do make changes to a contributed module, I would suggest putting it in the custom/ folder so you know not to upgrade that module without extracting your patches.
Why a separate folder for development modules
Development modules like devel, simpletest, trace and update_status should not be used on production or staging servers. These modules are typically only used in each developers individual working copy. This being the case, we do not want to include them in our SVN repository. In SVN you can mark folder or files to be ignored by the SVN client. I used to put all development modules in the contrib/ folder and set an ignore property on each individually, then realized if I grouped them all in a single folder, I could simply ignore that one folder making SVN management much easier.

Very nice info.
Earlier I used to copy all the modules to core drupal module folder. Then I started copying modules to site/all/modules folder, now as per your saying it will be much easier if we categories our modules in different folders as per need.
One quick question: Is there any code or settings to be done so that drupal recognize that the modules are actually in sites/all/modules/created_folder or will it ready on its own?
Thanks apeee
Determine the path to any module with the function
drupal_get_path(). For example, to determine the path to a custom module called “my_custom_module” you would use the following:<?php$path = drupal_get_path('module', 'my_custom_module');
?>
Thanks for the code.
But where should I keep it?
In one of my website contributed modules and themes are mixed with core modules and themes, respectively. It is very difficult to figure out specified modules in that big list. I want to separate them, should I just cut and paste the folder in the sites/all/contrib folder after adding the above code?
I see what you want to do. The best way to reorganize your module folders is to disable the modules you want to move first. Then move them to the new location and enable them again. Drupal will automatically figure out the new location.
Thank you very much.
It worked. I made two custom directory under under site/all/created_folder and copied and organized it as per need. Drupal automatically figured it out. Didn’t need any coding, may be the code that you have provided are for module development people.
But, I’m currently in learning phase, hope someday I’ll be contributing to community as well. :-)
Post new comment