F
F
Fastto2011-10-12 10:08:03
MediaWiki
Fastto, 2011-10-12 10:08:03

Custom prefix for content element in mediawiki

Task:
on a page in mediawiki, set the root index (prefix) to the number in the content, i.e. for example, somehow set the initial index to 4.1 and then in the content, and on the page

== First element ==
Will look like 4.1.1

== Second element ==
Will look like 4.1.2

=== First subelement of the second element = ==
Would look like 4.1.2.1

Is this even feasible? I looked through the documentation and didn't find anything like it.

Now I have to install _NOTOC_ and generate content manually, which is not very convenient.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
L
LDestroy, 2013-12-05
@LDestroy

I also faced the same problem... search on the Internet didn't give anything... I had to do it myself :)
In general, you need to edit the code a little:
/w/includes/parser/Parser.php

$toc .= Linker::tocLine( $anchor, $tocline,
                    $numbering, $toclevel, ( $isTemplate ? false : $sectionIndex ) );

replaced by
if (!empty($tocline)) {
                $toc .= Linker::tocLine( $anchor, $tocline,
                    $numbering, $toclevel, ( $isTemplate ? false : $sectionIndex ) );
                }

and
$head[$headlineCount] = Linker::makeHeadline( $level,     
                $matches['attrib'][$headlineCount], $anchor, $headline,
                $editlink, $legacyAnchor );

replaced by
if (!empty($tocline)) {                                   
            $head[$headlineCount] = Linker::makeHeadline( $level,     
                $matches['attrib'][$headlineCount], $anchor, $headline,
                $editlink, $legacyAnchor );                           
            }

now in the Wiki you can start the table of contents from the desired item:
__TOC__
== ==
== ==
== ==
== ==
=== ===
==== Test 1 ====
==== Test 2 = ===

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question