We relaunched the TWiki.org project with an expanded TWiki charter, and we invite you to participate! The TWiki.org Code of Conduct agreement took effect on 27 Oct 2008. We ask existing twiki.org users to opt-in. You need to opt-in to participate in the Blog, Codev, Plugins and TWiki webs. -- PeterThoeny - 27 Oct 2008
You are here: TWiki> Codev Web>TocOnNotCurrentTopicBroken (18 Jul 2004, PeterThoeny)
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

Topic revision: r2 - 18 Jul 2004 - 06:41:03 - PeterThoeny
 
TWIKI.NET
This site is powered by the TWiki collaboration platformCopyright © by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback