contrib modules - implementing hooks
carlescliment - October 2, 2009 - 14:46
My drupal app contains a module that defines his own hook. For each module I attach, I can implement the hook to extend its functionality.
Troubles come when I use contrib modules. Every time I download a newer version of the module, I must modify the contrib module in order to implement the mentioned hook.
Is there any way to simplify the task merging the code?
Lots of thanks.

Hello there, Can you describe
Hello there,
Can you describe what you're trying to accomplish? Most likely there is another way to go about it that wouldn't require hacking contributed modules.
Cheers,
Chris
Build a Module.com - The definitive video guide to Drupal development
The module I wrote overrides
The module I wrote (username_menu) overrides the theme('username') function, so it dinamically displays a basic menu whenever the username is clicked in forums or support pages.
Elements of the menu are extensible if provided by other modules with hooks. I.e., the app contains a module that allows admins to change certain user parameters. This module implements the "username_menu" hook and adds his own link to the username menu.
Now, I would like to attach the Troll module, and make it provide the needed hook to add options to the menu. As you say, my inital solution was hacking the module.
Any other idea?
Thanks for your attention.
P.S.: I DO want to use the hook to create menu links. Don't want to mantain the menu options in the username_menu module. Cheers!
I think you have two options.
I think you have two options. The first is instead of requiring other modules to plug into yours, you do a check to see if the module is installed and then make the adjustments in your module. If you still wanted to require other modules to plug into yours, then you could try creating patches of the changes you made and submitting them to the module issue queues to see if the authors will support your code. Doing so would also elicit some feedback about the module maintainers about what their preferences would be for integration (i.e., maybe they would prefer you support them within your own module).
Cheers,
Chris
Build a Module.com - The definitive video guide to Drupal development
Thanks a lot, Chris. I've
Thanks a lot, Chris.
I've been thinking on your proposals. I've discarded the second option, because I think it is too much work to do if it is needed to contact developers of each module I want to attach.
Better the first solution, but I don't like changing my user_menu.module when I want to add/remove elements to the menu.
Instead, I've been thinking on creating an inc file (module_name_user_menu.inc) in the contrib module directory and place there the hook function. Doing this, the inc file will be there even if I install a newer version of the module.
Is it possible?
Thanks again,
Carles