It surprised me that some people think it's not ok to alter contributed modules. Well, its not. It's a bad thing to adjust CORE modules! But that's another discussion. The idea is that before programming your own module you try to find one that already does most of what you want, but misses some features. you will code those features. Sometimes this involves only adding a few lines or adding only one function. Sometimes it involves a lot of programming.
The big problem with altering contributed modules is that you loose the ability to upgrade when a new version of the module is released. In an article about upgrading Drupal, Wim Mostrey proposes a simple solution to keep track of what you are changing.
I started of by dividing the non-core modules between those still in their original state to a "contrib" directory and those that were either completely custom or altered in a "custom" directory, to get the following tree structure:
/sites/all/modules/contrib
/sites/all/modules/customThis helps you identify what needs to happen and will also save a lot of work for future upgrades. I then started from a clean Drupal 5.3 installation, download the newest version of the modules in /contrib and then started a process of 1) moving the core changes to non-core modules and themes and 2) updating the /custom modules.
But this way, you're only keeping track of what modules have changed. My addition to this tip is that you make a copy of the files you alter and name it .contributed or .original or .backup or .whatever-you-get-my-point (example: tinymce.module.contributed). Now you are keeping track of what files are modified too! And as soon as you need to upgrade, make a quick diff and you know what has changed.
BTW. If you find yourself tweaking a contributed module, why not contribute your new features, improvements? Maybe someone else is looking for it too.
Comments
Hi Giovanni, no action is required if you've just added, changed or deleted a few lines of code.
Hi Davy.
I've just patched a file in the Organic Groups module.
Should I uninstall and resinstall (disable and reenable) the entire OG module to make the patch work? I've just added some line of code to og_views.inc, to make OG work better with the Views module.
Thanks and congratulations for your blog.
Giovanni
It's really nice trick, splitting non-core modules in two folders (/sites/all/modules/contrib and /sites/all/modules/custom).
Thanks.
Post new comment