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

Georgii’s picture

I 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.

markhalliwell’s picture

Title: Allow child theme to override parent's alter.inc » Base-theme's bootstrap.js causing issues
Version: 7.x-3.0 » 7.x-3.x-dev
Component: CSS Overrides » Code
Category: Feature request » Bug report
Status: Active » Closed (duplicate)
Related issues: +#2462645: Create @BootstrapPlugin for "bootstrap-anchor"

I'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.

Georgii’s picture

@markcarver Thank you for this important note about ordering of hooks. I did as you suggest and it works perfectly fine.