I do not know how to contribute code, but have developed the following "fix" that works to create TOCs when using the >Print Current Document feature in TW. This fixes the problem with the TOC growing to enormous length on a large page with each new section TOC being appended to the previous section's TOC. This fix has worked across many major versions.
File: tikiwiki/lib/parser/parserlib.php
Insertion point: in 12.0 line 2814; in 12.2 line 2967
Insert IMMEDIATELY BEFORE the following existing code:
if (!empty($maketoc)) { $maketoc = $maketoc_header.$maketoc.$maketoc_footer; }
Inserted code:
//=====larryg -- beginning of custom code to make TOC and MAKETOC work properly in tandem global $TOC_newstring, $TOC_oldstring ; $TOC_newstring = $maketoc ; //===== get a copy of the newest TOC before we do anything to it if ( strpos($maketoc, $TOC_oldstring) ) // larryg - if this MAKETOC contains previous chapter's TOC entries, remove that portion of the string { $maketoc = substr($maketoc, 0 , strpos($maketoc, $TOC_oldstring)).substr($maketoc, strpos($maketoc, $TOC_oldstring)+ strlen($TOC_oldstring)) ; } //prepare this chapter's TOC entry to be compared with the next chapter's string] $head_string = '<li><a href=' ; $tail_string = '<!--toc-->' ; if ( strpos($TOC_newstring, $head_string ) && strpos($TOC_newstring, $tail_string) ) { $TOC_newstring = substr($TOC_newstring, strpos($TOC_newstring, $head_string) ) ; // trim unwanted stuff from the beginning of the string // $maketoc_header = 'PRESTRINGFOUND'.$maketoc_header ; $TOC_newstring = substr($TOC_newstring, 0, (strpos($TOC_newstring, $tail_string) -5)) ; // trim the stuff from the tail of the string </ul></li></ul> // $maketoc_footer = 'POSTRINGFOUND' ; $TOC_oldstring = $TOC_newstring ; } //=====larryg -- end of custom code for TOC and MAKETOC
Please feel free to apply/use as you see appropriate,
-larryg
See comments to this item.
In addition, a show.t.o instance has been created where the issue is reproduced:
u: admin
p: 12345
As you can see, the table of contents in Chapter 2 ("3.2" in the numbering of the single html) shows the issue.
After applying your patch, I get the same issue still in this example.
You can test locally if you want by means of downloading a snapshot of the show instance.
To help developers solve the bug, we kindly request that you demonstrate your bug on a show2.tiki.org instance. To start, simply select a version and click on "Create show2.tiki.org instance". Once the instance is ready (in a minute or two), as indicated in the status window below, you can then access that instance, login (the initial admin username/password is "admin") and configure the Tiki to demonstrate your bug. Priority will be given to bugs that have been demonstrated on show2.tiki.org.
To help developers solve the bug, we kindly request that you demonstrate your bug on a show.tikiwiki.org instance. To start, simply select a version and click on "Create show.tikiwiki.org instance". Once the instance is ready (in a minute or two), as indicated in the status window below, you can then access that instance, login (the initial admin username/password is "admin") and configure the Tiki to demonstrate your bug. Priority will be given to bugs that have been demonstrated on show.tikiwiki.org.
filename | created | hits | comment | version | filetype | ||
---|---|---|---|---|---|---|---|
No attachments for this item |