Improving PDF TOCs with large wiki documents using mix of TOC and MAKETOC
- Status
- Closed
- Subject
- Improving PDF TOCs with large wiki documents using mix of TOC and MAKETOC
- Version
- 12.x
- Category
- Patch
- Feature
- Wiki Structure (book & table of content)
- Resolution status
- Fixed or Solved
- Submitted by
- larryg
- Lastmod by
- lindon
- Rating
- Related-to
- Description
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 2967Insert IMMEDIATELY BEFORE the following existing code:
Copy to clipboardif (!empty($maketoc)) { $maketoc = $maketoc_header.$maketoc.$maketoc_footer; }
Inserted code:Copy to clipboard//=====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 MAKETOCPlease 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: 12345As 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.
- Solution
- I'm guessing this was fixed with r52327 so I am closing this report. Please re-open if any issues.
- Importance
- 5
- Easy to solve?
- 8
- Priority
- 40
- Demonstrate Bug on Tiki 19+
-
This bug has been demonstrated on show2.tiki.org
Please demonstrate your bug on show2.tiki.org
Show.tiki.org is not configured properlyThe public/private keys configured to connect to show2.tiki.org were not accepted. Please make sure you are using RSA keys. Thanks.
- Demonstrate Bug (older Tiki versions)
-
This bug has been demonstrated on show.tikiwiki.org
Please demonstrate your bug on show.tikiwiki.org
Show.tiki.org is not configured properlyThe public/private keys configured to connect to show.tikiwiki.org were not accepted. Please make sure you are using RSA keys. Thanks.
- Ticket ID
- 5405
- Created
- Wednesday 06 August, 2014 13:59:23 UTC
by larryg - LastModif
- Saturday 14 November, 2015 02:03:46 UTC