Extension:DeToc

From MediaWiki.org
Jump to navigation Jump to search
MediaWiki extensions manual
OOjs UI icon advanced.svg
DeToc
Release status: stable
Implementation MyWiki
Description Extracts and removes the table of contents from the page
Author(s) Marcin Cieślak, contracted by Viato GmbH (sapertalk)
Latest version 1.0.0 (2015-10-16)
MediaWiki 1.25+
License GNU General Public License 3.0 or later
Download external tarball
Example Naiad.skin.php line 69
Translate the DeToc extension if it is available at translatewiki.net
Check usage and version matrix.

The DeToc extension extracts and removes the table of contents of a wiki article. In order to work the functions provided by this extension need to be used by the current skin. It is useful for skin programming to move the ToC into a different part of the page.

Usage[edit]

Add the following to your LocalSettings.php:

wfLoadExtension( 'DeToc' );

Then include the following line in your skin's BaseTemplate::execute() method:

$new_body = DeToc::RemoveToc( $this->data[ 'bodycontent' ], $extracted_toc );

This way the $new_body variable will contain the article body in HTML without table of contents. The $extracted_toc variable will contain the table of contents without the initial <div id="toc"> and the final </div>.

This extension is used in the updated Naiad skin to move the table of contents to another area of the screen.

See also[edit]