Jump to content

Extension:TocTree: Difference between revisions

From mediawiki.org
Content deleted Content added
wikivoyagetech>Unger
m 26 revisions imported: Import history from "TocTree extension" in https://archive.org/details/wiki-wikivoyage_oldorg_w_tech
 
(33 intermediate revisions by 22 users not shown)
Line 1: Line 1:
<languages/>
This extension was written to modify the table of contents (toc). The main entries will get toggles to expand or collapse the toc trees.
{{Extension
|name = TocTree
|status = stable
|type1 = interface
|type2 =
|username =
|author =
|description = <translate><!--T:1--> Allows for expansion and collapsing of the table of contents</translate>
|changelog =
|parameters =
|tags =
|rights =
|example =
|compatibility =
|download = {{WikimediaDownload}}
|phabricator = MediaWiki-extensions-TocTree
}}
<translate>
<!--T:6-->
The <tvar name=1>'''TocTree'''</tvar> extension allows for initial expansion and collapsing of the table of contents.


==Installation== <!--T:2-->
== License ==
</translate>
{{ExtensionInstall
|TocTree
|registration=required
}}


<translate>
GPL.
== Customization == <!--T:3-->

== Installing TocTree ==

Download 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):

<source lang="php">
require_once( "$IP/extensions/TocTree/TocTree.php" );
</source>

== Customization ==


<!--T:7-->
The PHP script will add two new options to the user preferences. They were added to the Misc section:
The PHP script will add two new options to the user preferences. They were added to the Misc section:
</translate>
* Floated table of contents
* Expand table of contents


* <translate><!--T:8--> Floated table of contents</translate>
Defaults are collapsed but not floated tocs. You can overwrite the default values by setting true in your LocalSettings.php file:
* <translate><!--T:9--> Expand table of contents</translate>


<translate><!--T:10--> Defaults are collapsed but not floated tocs.</translate>
<source lang="php">
You can overwrite the default values by setting true in your LocalSettings.php file:
$wgDefaultUserOptions ['toc-floated'] = false;
$wgDefaultUserOptions ['toc-expand'] = false;
</source>


<syntaxhighlight lang="php">
== Prevention of TOC floating ==
$wgDefaultUserOptions['toc-floated'] = false;
$wgDefaultUserOptions['toc-expand'] = false;
</syntaxhighlight>


<translate>
== Prevention of TOC floating == <!--T:4-->
</translate>
The author has the opportunity to prevent floating of the TOC set by the user(s) by using a <code>div</code> tag with the style class <code>noFloat</code> enclosing the TOC.
The author has the opportunity to prevent floating of the TOC set by the user(s) by using a <code>div</code> tag with the style class <code>noFloat</code> enclosing the TOC.


<pre>
<code><nowiki><div class="noFloat">__TOC__</div></nowiki></code>
<div class="noFloat">__TOC__</div>
</pre>


<translate>
== Used messages ==
== Known problems == <!--T:5-->


<!--T:11-->
Message strings ― noted in TocTree.i18n.php ― are available now for three languages (de, en, and pl).
There are the well-known problems of floated boxes like:
</translate>


* <translate><!--T:12--> Missing list bullets</translate>
<source lang="php">
* <translate><!--T:13--> Design problems of narrow TOCs and positioning problems with text and wide right-floated boxes.</translate>
<?php
/*
* Internationalisation file for TocTree extension.
*
* @package MediaWiki
* @subpackage Extensions
*/


<translate>
$TocTreeMessages = array();
<!--T:14-->
Additional:
</translate>


* <translate><!--T:15--> Bidi support (right-to-left writing direction) implemented but not yet tested (for instance needed for Hebrew and Arabic).</translate>
$TocTreeMessages['en'] = array(
* <translate><!--T:16--> Support of only the MonoBook and Vector skins.</translate>
'tog-toc-expand' => 'Expand table of contents',
'tog-toc-floated' => 'Floated table of contents',
);


{{OnWikimedia}}
$TocTreeMessages['de'] = array(
{{Used by}}
'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',
);

?>
</source>

== Known Problems ==

There are the well-known problems of floated boxes like:

* Missing list bullets, see for instance [http://css-discuss.incutio.com/?page=MissingBulletPoints Missing Bullet Points]
* Design problems of narrow tocs and positoning problems with text and wide right-floated boxes.

Additional:


[[Category:TOC extensions{{#translation:}}]]
* Bidi support (right-to-left writing direction) not yet implemented (for instance needed for Hebrew and Arabic). The direction is noted in both the <nowiki><html ... dir=""></nowiki> and the <nowiki><body ... class="... rtl"></nowiki> tags. Can be solved by using CSS.
* Tested only with Monobook skin.

Latest revision as of 17:36, 10 May 2025

MediaWiki extensions manual
TocTree
Release status: stable
Implementation User interface
Description Allows for expansion and collapsing of the table of contents
Author(s) Roland Unger, Matthias Mullie
Latest version 1.12.0
MediaWiki >= 1.47.0
Licence GNU General Public License 2.0 or later
Download
Translate the TocTree extension if it is available at translatewiki.net
Issues Open tasks · Report a bug

The TocTree extension allows for initial expansion and collapsing of the table of contents.

Installation

[edit | edit source]
  • Download and move the extracted TocTree folder to your extensions/ directory.
    Developers and code contributors should install the extension from Git instead, using:
    cd extensions/
    git clone https://gerrit.wikimedia.org/r/mediawiki/extensions/TocTree
    
  • Add the following code at the bottom of your LocalSettings.php file:
    wfLoadExtension( 'TocTree' );
    
  • Yes Done – Navigate to Special:Version on your wiki to verify that the extension is successfully installed.

Customization

[edit | edit source]

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

[edit | edit source]

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>

Known problems

[edit | edit source]

There are the well-known problems of floated boxes like:

  • Missing list bullets
  • Design problems of narrow TOCs and positioning problems with text and wide right-floated boxes.

Additional:

  • Bidi support (right-to-left writing direction) implemented but not yet tested (for instance needed for Hebrew and Arabic).
  • Support of only the MonoBook and Vector skins.