Extension:TocTree
This extension was written to modify the table of contents (toc). The main entries will get toggles to expand or collapse the toc trees.
Installing TocTree
Donwload from svn:mediawiki/trunk/extensions/TocTree. Copy TocTree.php, TocTree.i18n.php, TocTree.js, TocTree.css, TocTreeCollapsed.css, and TocTreeFloated.css into the TocTree folder in the extensions folder of your MediaWiki installation. Then add the following line to your LocalSettings.php file (near the end):
require_once( "$IP/extensions/TocTree/TocTree.php" );
Customization
The PHP script will add two new options to the user preferences. They were added to the Misc section:
- Floated table of contents
- Expand table of contents
Defaults are collapsed but not floated tocs. You can overwrite the default values by setting true in your LocalSettings.php file:
$wgDefaultUserOptions ['toc-floated'] = false;
$wgDefaultUserOptions ['toc-expand'] = false;
Prevention of TOC floating
The author has the opportunity to prevent floating of the TOC set by the user(s) by using a div tag with the style class noFloat enclosing the TOC.
<div class="noFloat">__TOC__</div>
Used messages
Message strings ― noted in TocTree.i18n.php ― are available now for three languages (de, en, and pl).
<?php
/*
* Internationalisation file for TocTree extension.
*
* @package MediaWiki
* @subpackage Extensions
*/
$TocTreeMessages = array();
$TocTreeMessages['en'] = array(
'tog-toc-expand' => 'Expand table of contents',
'tog-toc-floated' => 'Floated table of contents',
);
$TocTreeMessages['de'] = array(
'tog-toc-expand' => 'Vollständiges Inhaltsverzeichnis',
'tog-toc-floated' => 'Umflossenes Inhaltsverzeichnis',
);
$TocTreeMessages['fr'] = array(
'tog-toc-expand' => 'Etendre le sommaire',
'tog-toc-floated' => 'Sommaire flottant',
);
$TocTreeMessages['it'] = array(
'tog-toc-expand' => 'Espandi il sommario',
'tog-toc-floated' => 'Floated table of contents',
);
$TocTreeMessages['pl'] = array(
'tog-toc-expand' => 'Rozwijanie spisu treści',
'tog-toc-floated' => 'Opływanie spisu treści',
);
?>
Known Problems
There the the well-known promlems of floated boxes like:
- Missing list bullets, see for instance Missing Bullet Points
- Design problems of narrow tocs and positoning problems with text and wide right-floated boxes.