Extension:Bootstrap

From MediaWiki.org
Jump to navigation Jump to search
MediaWiki extensions manual
OOjs UI icon advanced.svg
Bootstrap
Release status: stable
Implementation Skin
Description Provides the Bootstrap 4 web front-end framework
Author(s) Stephan Gambke (F.trotttalk)
Latest version 4.0 (2019-04-29)
Compatibility policy master
MediaWiki 1.27+
PHP 5.6+
Database changes No
Composer mediawiki/bootstrap
License GNU General Public License 3.0 or later
Download
README on GitHub
Changelog on GitHub
Translate the Bootstrap extension if it is available at translatewiki.net
Check usage and version matrix.

The Bootstrap extension provides the Bootstrap 4 web front-end framework to MediaWiki. It can be activated directly or used from skins or extensions.

Currently Bootstrap version 4.3.1 is provided.

Installation[edit]

The Bootstrap extension requires Composer for installation. (But why!?)

  1. If not already done, install Composer.
  2. Add mediawiki/bootstrap: ~4.0 as a requirement to your "composer.local.json" file in the MediaWiki installation directory
  3. Run composer update --no-dev "mediawiki/bootstrap"
  4. Load the extension by adding the following line to LocalSettings.php: wfLoadExtension( 'Bootstrap' );
  5. Yes Done – Navigate to "Special:Version" on your wiki to verify that the extension is successfully installed.

Remark: It is NOT necessary to install or load any extensions this extensions depends on.

Usage[edit]

Use \Bootstrap\BootstrapManager::getInstance() to get the singleton managing the Bootstrap framework.

With the returned object,

  • add Bootstrap modules using addBootstrapModule(), addCoreBootstrapModules(), and addAllBootstrapModules()
  • set SCSS variables using setScssVariable() and setScssVariables()
  • add style files using addStyleFile()
  • add cache trigger files using addCacheTriggerFile()

Finally to add the Bootstrap styles and javascript to the page use $out->addModuleStyles( 'ext.bootstrap.styles' ) for styles and $out->addModules( 'ext.bootstrap.scripts' ) for scripts.

To simply enable Bootstrap styles on all pages add the following code to your "LocalSettings.php" file:

$wgHooks['SetupAfterCache'][] = function(){
	\Bootstrap\BootstrapManager::getInstance()->addAllBootstrapModules();
	return true;
};


$wgHooks['ParserAfterParse'][]=function( Parser &$parser, &$text, StripState &$stripState ){
	$parser->getOutput()->addModuleStyles( 'ext.bootstrap.styles' );
	$parser->getOutput()->addModules( 'ext.bootstrap.scripts' );
	return true;
};

For an example on how to include Bootstrap styles in a skin have a look at the Chameleon skin.

Contact[edit]

Comments, questions and suggestions should be sent or posted to:

See also[edit]

Directly related[edit]

  • the Bootstrap framework homepage
  • the SASS/SCSS homepage
  • the Chameleon skin that uses this extension
  • the BootstrapComponents extension that uses this extension and lets editors utilize its potential inside wiki markup (not yet available for Bootstrap 4)

Disambiguation[edit]

  • the BootStrap extension (note the exact spelling of the name!) aims to allow for the addition of Bootstrap styling within MediaWiki articles
  • the BootStrapSkin skin makes use of the BootStrap extension
  • the Bootstrap skin is another Bootstrap based skin independent from either extension