Tags:
create new tag
view all tags

Bug: TOC on topic other then the current one is broken

If you show a table of content for another topic you get relative links to the current topic instead of links to the other topic. That is, the links do not work.

This bug was introduced recently with the TOCLinkURIRefsNotRelative fix.

Test case

  • Create a topic with some headings, name it TestTocA
  • Write a TOC in another topic, TestTocB, referencing that topic, e.g. %TOC{TestTocA}%
  • It points to headings in TestTocB instead of TestTocA

Environment

TWiki version: TWikiRelease01Feb2003
TWiki plugins: DefaultPlugin, EmptyPlugin, InterwikiPlugin
Server OS:  
Web server:  
Perl version:  
Client OS:  
Web Browser:  

-- PeterThoeny - 18 Jul 2004

Follow up

Fix record

Fix is in SVN. Not marked as Cairo fix since introduced recently.

Index: TWiki.pm
===================================================================
--- TWiki.pm    (revision 1575)
+++ TWiki.pm    (working copy)
@@ -154,7 +154,7 @@

 # ===========================
 # TWiki version:
-$wikiversion      = 'Alpha 15 Jul 2004 $Rev$';
+$wikiversion      = 'Alpha 17 Jul 2004 $Rev$';

 # ===========================
 # Key Global variables, required for writeDebug
@@ -2422,6 +2422,11 @@
                 $level =~ s/$regex{headerPatternHt}/$1/gio;
                 $line  =~ s/$regex{headerPatternHt}/$2/gio;
             }
+            my $urlPath = "";
+            if( "$web.$topicname" ne "$webName.$topicName" ) {
+                # not current topic, can't omit URL
+                $urlPath = "$dispScriptUrlPath$dispViewPath$scriptSuffix/$webPath/$topicname";
+            }
             if( ( $line ) && ( $level <= $depth ) ) {
                 $anchor = TWiki::Render::makeAnchorName( $line );
                 # cut TOC exclude '---+ heading !! exclude'
@@ -2444,7 +2449,7 @@
                 $line =~ s/([\s\(])($regex{wikiWordRegex})/$1<nop>$2/g;  # 'TopicName'
                 $line =~ s/([\s\(])($regex{abbrevRegex})/$1<nop>$2/g;    # 'TLA'
                 # create linked bullet item, using a relative link to anchor
-                $line = "$tabs* <a href=\"#$anchor\">$line</a>";
+                $line = "$tabs* <a href=\"$urlPath#$anchor\">$line</a>";
                 $result .= "\n$line";
             }
         }

-- PeterThoeny - 18 Jul 2004

Edit | Attach | Watch | Print version | History: r2 < r1 | Backlinks | Raw View | Raw edit | More topic actions
Topic revision: r2 - 2004-07-18 - PeterThoeny
 
  • Learn about TWiki  
  • Download TWiki
This site is powered by the TWiki collaboration platform Powered by Perl Hosted by OICcam.com Ideas, requests, problems regarding TWiki? Send feedback. Ask community in the support forum.
Copyright © 1999-2026 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.