I'm trying to make a "bridge" module that will enable 2 custom modules (ModA and ModB) to work together without modifying the code of either of the 2 modules.

ModA implements hook_footer to add some javascript code at the end of the page. I want to "intercept" this hook call from my custom module and add my own javascript code. Basically, I want to add another conditional in there and ultimately make the module generate different javascript code if a certain condition is met. Is this possible? I do not want to change the original module if it is not absolutely necessary to do so (afaik there are some people that could use this module and I was thinking of uploading it to drupal.org - can't do that if I have to change core code of another module though -).

Another solution that I thought about, is to use a regular expression and modify the custom javascript after it has been generated by ModA.

Please let me know what you think.

Thanks in advance for your responses.

Comments

jaypan’s picture

Look at the javascript alter module. You can either use it, or see how they do it, whichever suits your needs better.

Contact me to contract me for D7 -> D10/11 migrations.