I try to exclude CSS and JS on the .info of a subtheme without success. If I do it directly in twitter_bootstrap theme it works.

The problem certainly append in twitter_bootstrap_theme_get_info called by twitter_bootstrap_css_alter and twitter_bootstrap_js_alter.

Comments

kalabro’s picture

It works for my subtheme fine both for css and js.

core = 7.x
base theme = twitter_bootstrap
stylesheets[all][] = css/styles.css
...
...
exclude[js][] = 'misc/jquery.js'                   ; works
exclude[js][] = 'modules/contextual/contextual.js' ; works
exclude[css][] = 'modules/user/user.css'           ; again works
frankbaele’s picture

Status: Active » Closed (cannot reproduce)
jhuon’s picture

In order to benefits from all the LESS functions, I personnaly use my own compiled version of Bootstrap.
I try to exclude the Twitter Bootstrap CSS and JS files with no luck. Here's what my sub-theme .info file looks like:

name = My Twitter Bootstrap's sub-theme
description = A Twitter Bootstrap's sub-theme
core = 7.x
base theme = twitter_bootstrap

exclude[css][] = 'bootstrap/css/bootstrap.css'
exclude[css][] = 'bootstrap/css/bootstrap-responsive.css'
stylesheets[all][] = css/style.css

exclude[js][] = 'bootstrap/js/bootstrap.js'
scripts[] = js/bootstrap.js
andregriffin’s picture

Project: Twitter's Bootstrap » Bootstrap
RobKoberg’s picture

Status: Closed (cannot reproduce) » Active

I have the same problem. I am trying to exclude the bootstrap pre-compiled JS and CSS for some of my multi-sites (using compass and SASS instead). An example theme .info file is:

name = Read for My School - UK
version = 2.0
core = 7.x

base theme = bootstrap

stylesheets[all][] = css/style.css

;scripts[] = js/bootstrap.js
scripts[] = js/bootstrap-transition.js
;scripts[] = js/bootstrap-affix.js
scripts[] = js/bootstrap-alert.js
scripts[] = js/bootstrap-button.js
;scripts[] = js/bootstrap-carousel.js
scripts[] = js/bootstrap-collapse.js
scripts[] = js/bootstrap-dropdown.js
scripts[] = js/bootstrap-modal.js
;scripts[] = js/bootstrap-scrollspy.js
scripts[] = js/bootstrap-tab.js
scripts[] = js/bootstrap-tooltip.js
scripts[] = js/bootstrap-popover.js
;scripts[] = js/bootstrap-typeahead.js

;scripts[] = js/jquery.timeago.js
scripts[] = js/tempo.js

exclude[js][] = 'bootstrap/js/bootstrap.js'

exclude[css][] = 'bootstrap/css/bootstrap.css'
exclude[css][] = 'bootstrap/css/bootstrap-responsive.css'

RobKoberg’s picture

To be a little more clear on this, you would have needed to download the bootstrap precompiled directory/files into the main bootstrap theme directory. I am doing this because as a new site in a multi-site environment is started, they won't have styles yet or even a subtheme. I have a custom install profile select the bootstrap theme instead of the theme the standard install profile uses.

frankbaele’s picture

yes, i dont think the current code holds subthemes in account, but it shouldn't be that hard to fix. The problem lays within the fact that the code only checks the current themes code and doesnt consider the fact there maybe is a subtheme. I think the solution lays within the code written in conditional stylesheest module.

RobKoberg’s picture

We can get around this issue if we do something like:

/**
 * Implements hook_js_alter().
 */
function bootstrap_js_alter(&$js) {
  global $theme;
  if ($theme == 'bootstrap') {

What do you think?

mmowers’s picture

I had a similar problem and found that basing the exclude[] statement path on the drupal root was the solution. For example, to exclude bootstrap-responsive.css, I am using this statement:

exclude[css][] = 'sites/all/themes/bootstrap/bootstrap/css/bootstrap-responsive.css'

and it seems to work fine.

natted’s picture

I've been working on a solution for this (which also relates to a few other open issues).

I'm at Drupalcon Sydney this week but will try update with a proposed patch asap.

chriz001’s picture

I managed to do this with the following code

; Exclude
stylesheets[all][] = bootstrap/css/bootstrap.css
stylesheets[all][] = bootstrap/css/bootstrap-responsive.css

The base theme and the sub-theme must have the same entry:
stylesheets[all][] = masterStyle.css

If the file exists inside the sub-theme, it will be used; omitting the file in the sub-theme will prevent the file from loading from the base theme as well.

http://drupal.org/node/263967

robertom’s picture

Hi, sorry for my bad english.

I've solved this issue with this code:

inside my subtheme.info I've wrote

;Exclude
;css
exclude[css][] = sites/all/themes/bootstrap/bootstrap/css/bootstrap.css
exclude[css][] = sites/all/themes/bootstrap/bootstrap/css/bootstrap-responsive.css

;Exclude
;javascript
exclude[js][] = sites/all/themes/bootstrap/bootstrap/js/bootstrap.js

after that, I've created a template.php for my subtheme with


/**
 * Implements hook_js_alter().
 */
function subtheme_js_alter(&$js) {
  // _bootstrap_alter is a "private" function of bootstrap base theme
  $excludes = _bootstrap_alter(bootstrap_theme_get_info('exclude'), 'js');
  $js = array_diff_key($js, $excludes);
}

/**
 * Implements hook_css_alter().
 */
function subtheme_css_alter(&$css) {
  // _bootstrap_alter is a "private" function of bootstrap base theme
  $excludes = _bootstrap_alter(bootstrap_theme_get_info('exclude'), 'css');
  $css = array_diff_key($css, $excludes);
}

obviously you need to replace the word "subtheme" in the template.php file with the name of your theme

markhalliwell’s picture

Status: Active » Fixed

This isn't a problem with the new sub-theme methods added with the #1844448: Add sub-theme starter kit commit. Now, a sub-theme must either use the Boostrap CDN or supply it's own CSS and JS. There isn't a need for excluding anything as the base theme no longer attempts to load the Bootstrap library.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

Anonymous’s picture

Issue summary: View changes

it works in the base theme