Forum:Always show table of contents
ShoutWiki — express yourself and be heard!
Jump to navigation
Jump to search
Forums: Index → Community help
Hello, for my wiki TV-Programme I'd like to have the settings changed in order that a table of contents automatically appears already starting with 1 heading. So far, the TOC appears only with 4 or more headings, so I have to add __FORCETOC__
everytime when there are only 3 headings or less.
Could you please help me?
I read somewhere that you have to set "tocminheads=1" in "LocalSettings.php". It would help me a lot if you could change that for me. Thank you! --Alvine (talk) 20:13, 7 May 2019 (UTC)
- I don't see tocminheads supported in LocalSettings.php. See mw:Manual:Configuration settings. There is mw:Extension:ForceTocOnEveryPage, which may get you what you want. It looks pretty simple. It prepends
<?php /* * MediaWiki extension to force TOC on every page * Installation instructions can be found on * https://www.mediawiki.org/wiki/Extension:ForceTocOnEveryPage * * @author Jmkim dot com * @license http://opensource.org/licenses/gpl-license.php GNU Public License * @package MediaWikiExtensions */ if( !defined( 'MEDIAWIKI' ) ) exit; $wgExtensionCredits['parserhook'][] = array( 'name' => 'ForceTocOnEveryPage', 'version' => '1.0.4', 'description' => 'Forces a table of contents to be displayed on every page', 'author' => '[http://www.jmkim.com/ Jmkim dot com]', 'url' => 'https://www.mediawiki.org/wiki/Extension:ForceTocOnEveryPage' ); $wgHooks['InternalParseBeforeLinks'][] = 'ForceTocOnEveryPage_renderForceToc'; function ForceTocOnEveryPage_renderForceToc( &$parser, &$text ) { global $mediaWiki; if( !isset($mediaWiki) ) return true; if( $parser->getTitle()->getNamespace() != 0 ) return true; if( $parser->getTitle()->equals(Title::newMainPage()) ) return true; $text .= "__FORCETOC__"; return true; }
__FORCETOC__
to every mainspace page (except the main page) before it's fed to the parser. For a specific config change, you should use s:w:tvprogramme:Special:Contact or email troppusmoc.ikiwtuohs. --Saftzie (talk) 02:42, 9 May 2019 (UTC)