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.
Bootstrap.js is causing problems with a side menu plugin I'm using (http://mmenu.frebsite.nl/). I'd like to be able to modify alter.inc, place it in /child_theme/theme, and change $bootstrap = $theme_path . '/js/bootstrap.js';
to $bootstrap = $theme_path . '/js/bootstrap-fixed.js';
.
Comments
Comment #1
Georgii CreditAttribution: Georgii commentedI have pretty similar issue. @janebootydoe you probably could achieve the same by implementing a hook_js_alter. In the bootstrap theme there is a good example of how this can be achieved. That what I was trying to do
However there is an issue (and I'm not sure if it directly relates to the bootstrap theme. I'm not able to make Drupal call my hook after bootstrap_js_alter is executed. So I'm not able to override JS files added by the bootstrap theme.
Note: I have tried setting up my module's weight. But even if it's 999 then bootstrap_js_alter is called last anyway.
Please help. How to call a hook_js_alter after bootstrap_js_alter.
Comment #2
markhalliwellI'm re-categorizing based on the first sentence: "Bootstrap.js is causing problems with a side menu plugin I'm using"
I'm closing as a duplicate because of the related issue I'm attaching here (you can see the many issues that anchor JS has caused from there).
Now, as far as "hook_js_alter" bit goes, that can only be done in a sub-theme of this project. This project is not a module, it is a base-theme. Theme alter hooks are always invoked after modules, that is how drupal_alter() works.
Your sub-theme would have to alter the JS array after this base-theme does so it can replace the "bootstrap.js" file with its own... but I would highly recommend against that as you will have issues upgrading in the future. Instead you should be searching for related issues and/or creating new bug reports with existing code.
Comment #3
Georgii CreditAttribution: Georgii commented@markcarver Thank you for this important note about ordering of hooks. I did as you suggest and it works perfectly fine.