Create your own custom override module
If you've ever developed for Drupal, you know that there are times where it seems very tempting to hack a core or contributed module. Maybe you want to change some text, or add in some extra functionality to forms. While yes it might be quicker to hack the module, you're opening yourself up to a lot of potential problems.
- When new versions of the module come out, they will override any of your hacks
- You may forget what updates you made
- You may open up security vulnerabilities
- If someone new works on the site, they would not be aware of the hacks you made
- If running a multi-site installation, your hacks could have unintended affects on other sites.
While there may be a rare case where a hack is necessary, in most cases you don't need to.
So how do you cleanly override modules?
For most sites, the best approach is to create a custom override module. This keeps all your modules intact allowing for much easier future upgrades. Too, it centralizes your overrides in one place, which will make any future updates much easier to find and manage.
For anyone new to creating Drupal modules, attached is a simple skeleton of a Drupal 6 module. You can use this as a spring board for making all your text and behaviour overrides.
Attached module contents
- custom.info
- .info files are required for Drupal 6.x modules. Basically it lays out naming, description on admin/build/modules, etc...
- custom.install
- While install files are optional, since this is going to be a custom override module for every module you have installed before or after this one, we need to set the weight of the module. If your module executes before the module you're attempting to override, you won't see any changes. Setting the weight will ensure that your module executes last.
- custom.module
- This will be where you make all your custom overrides. For more information about hooks, check out http://api.drupal.org/api/group/hooks
Steps
- Unzip module to sites/all/modules or wherever you typically install your contributed modules
- Optional:
- Rename 'custom' folder & files to whatever you'd like to call your custom override module
- Replace all occurances of 'custom' within the files to whatever you've decided to name your module
- Enable the module at sites/all/modules
Add comment
Files
jsfwd on Twitter
- BIXI debuts bike sharing program in Toronto http://bit.ly/cTruQl 1 day 21 hours ago
- Vote #Toronto to host DrupalCon 2012 North America http://bit.ly/aXgBkJ 3 days 19 hours ago
- Toronto #Drupal meetup tonight 6:30pm @CSI http://bit.ly/cGL63w 4 days 20 hours ago
- Display a Twitter Profile using YQL & jQuery http://bit.ly/ajAfu6 5 days 21 hours ago
- Google Images got a facelift.... size, type & colour filters... pagers gone... wow! 1 week 2 days ago
- Wouldn't that just be Drupal? RT @becircle: I just heard the words I feared I might hear some day "They created a GUI for Drush" #drupal 1 week 3 days ago
- #Raptors acquire Leandro Barbosa... w00t w00t!! 2 weeks 5 days ago
- The NBA is a whole lot less interesting today. 3 weeks 22 hours ago
- Site Aliases, Groups and Remote Capabilities! RT @lwalk: New features in Drush 3 http://bit.ly/aIzmxw #drush #drupal 4 weeks 2 days ago
- Twitter delays the OAuthcalypse another 6 weeks http://countdowntooauth.com 4 weeks 3 days ago