Jump to content

Extension:DeToc

From mediawiki.org
MediaWiki extensions manual
DeToc
Release status: unmaintained
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)
Compatibility policy Master maintains backward compatibility.
MediaWiki 1.25+
License GNU General Public License 3.0 or later
Download external tarball
Example Naiad.skin.php line 69

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]