Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
By gracefulpig on
I ran into this trouble:
I want to use javascript to modify the display of one module (module1) from another module (module2). That is to say, module2 has a couple of .js files and maybe a sort of "hook_theme_alter" function that are used to modify the display of some widgets in module1. module1, however, does not know the existence of module2. I cannot see the hook_theme_registry_alter can do this job.
Thanks a lot.
Comments
Javascript doesn't care what
Javascript doesn't care what module it comes from. Just include the JS file on the page it needs to be included on, and it will execute.
Module2 redirects to module1
Thank you Jaypan. The thing was, drupal runs to module2, which processes something, and then is redirected to the page generated by module1. So when the module1 was running, how the javascripts can be loaded from module2? In other words, how can module2 notice when the module1 is running and then add javascripts in itself module to the pages generated by module1?
Your question is too generic
Your question is too generic to understand. Please explain specifically what you are trying to do, and what is not working.
reply:
Sorry about the confusion. I just figure it out by myself, using the module_preprocess_hook function.
Thanks.