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.
<?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;
}
It prepends __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)
Thank you for your help! As I don't have access to LocalSettings.php, I think I will have to contact the support. --Alvine (talk) 19:09, 9 May 2019 (UTC)
How much time does it usually take until you get an answer from Shoutwiki support? --Alvine (talk) 12:29, 27 May 2019 (UTC)
It can vary and be a while. --Saftzie (talk) 16:24, 27 May 2019 (UTC)