Changing the structure of page’s table of contents

Fragment of a discussion from Project:Support desk
Jump to: navigation, search

Thank you very much! In file includes/Linker.php I change such function

 function tocLine( $anchor, $tocline, $tocnumber, $level, $sectionIndex = false ) {
                $classes = "toclevel-$level";
                if ( $sectionIndex !== false )
                        $classes .= " tocsection-$sectionIndex";
                return "\n<li class=\"$classes\"><a href=\"#" .
                        $anchor . '"><span class="tocnumber">' .
                        $tocnumber . '</span> <span class="toctext">' .
                        $tocline . '</span></a>';
        }

to

 function tocLine( $anchor, $tocline, $tocnumber, $level, $sectionIndex = false ) {
                $tocnumber = "$tocnumber. ";
                $classes = "toclevel-$level";
                if ( $sectionIndex !== false )
                        $classes .= " tocsection-$sectionIndex";
                return "\n<li class=\"$classes\"><a href=\"#" .
                        $anchor . '"><span class="tocnumber">' .
                        $tocnumber . '</span> <span class="toctext">' .
                        $tocline . '</span></a>';
        }

As a result it works and does not even conflict with Extension:PSINoTocNum. Now I'm trying to add a dot in the numbering of sections, which I do with Extension:MagicNumberedHeadings. Where created the text of the header? Any ideas?

ZelChief12:10, 18 December 2011

I solve my problem =) So, in file /includes/parser/Parser.php I change such function

function formatHeadings( $text, $origText, $isMain=true )

Then, after such code

                        # count number of headlines for each level
                        @$sublevelCount[$toclevel]++;
                        $dot = 0;
                        for( $i = 1; $i <= $toclevel; $i++ ) {
                                if ( !empty( $sublevelCount[$i] ) ) {
                                        if ( $dot ) {
                                                $numbering .= '.';
                                        }
                                        $numbering .= $wgContLang->formatNum( $sublevelCount[$i] );
                                        $dot = 1;
                                }
                        }

I add this

$numbering .= '.';

And ... it works.

ZelChief18:42, 18 December 2011
 
Personal tools

Variants
Actions
Navigation
Support
Download
Development
Communication
Toolbox