• Do not register here on develop.twiki.org, login with your twiki.org account.
• Use View topic Item7848 for generic doc work for TWiki-6.1.1. Use View topic Item7851 for doc work on extensions that are not part of a release. More... Close
• Anything you create or change in standard webs (Main, TWiki, Sandbox etc) will be automatically reverted on every SVN update.
Does this site look broken?. Use the LitterTray web for test cases.

Item7286: Support TOC in skin

Item Form Data

AppliesTo: Component: Priority: CurrentState: WaitingFor: TargetRelease ReleasedIn
Engine   Normal Closed   major 6.0.0

Edit Form Data

Summary:
Reported By:
Codebase:
Applies To:
Component:
Priority:
Current State:
Waiting For:
Target Release:
Released In:
 

Detail

Currently it is not possible to have a TOC in a skin because the TOC handling only loads the topic text if the TOC has to be built for another topic. The TOC fails because the skin handling is done in the context of the current topic and ths skin does not have the topic content.

This fixes the issue by checking if TOC is in skin context. If so, it reads the topic text before building the TOC.

-- TWiki:Main/PeterThoeny - 2013-06-27

This is now in SVN trunk and 5.1 branch.

Patch for TWiki-5.1.x:

--- TWiki.pm   (revision 26021)
+++ TWiki.pm   (working copy)
@@ -1921,6 +1921,7 @@
     undef $this->{user};
     undef $this->{SESSION_TAGS};
     undef $this->{_INCLUDES};
+    undef $this->{ignoreTOC};
     undef $this->{response};
     undef $this->{evaluating_if};
 }
@@ -2229,6 +2230,8 @@
 sub _TOC {
     my ( $this, $text, $defaultTopic, $defaultWeb, $args ) = @_;
 
+    return '' if( $this->{ignoreTOC} ); # prevent infinite recursion
+
     require TWiki::Attrs;
 
     my $params = new TWiki::Attrs( $args );
@@ -2253,7 +2256,9 @@
     my $title = $params->{title} || $this->{prefs}->getPreferencesValue('TOC_TITLE') || '';
     $title = CGI::span( { class => 'twikiTocTitle' }, $title ) if( $title );
 
-    if( $web ne $defaultWeb || $topic ne $defaultTopic ) {
+    # Item7286: Load topic text if TOC is built for another topic,
+    # or if in skin context of the current topic
+    unless( $isSameTopic && $this->inContext( 'body_text' ) ) {
         unless( $this->security->checkAccessPermission
                 ( 'VIEW', $this->{user}, undef, undef, $topic, $web ) ) {
             return $this->inlineAlert( 'alerts', 'access_denied', $web, $topic );
@@ -2261,13 +2266,13 @@
         my $meta;
         ( $meta, $text ) = $this->{store}->readTopic( $this->{user}, $web, $topic );
 
-        # Item7166: Escape %TOC% to avoid infinite recursion.
-        $text =~ s/%(TOC[{%])/%<nop>$1/g;
-
+        # prevent infinite recursion - could happen if there is a TOC in the text or in INCLUDE
+        $this->{ignoreTOC} = 1;
         # Item6864: 2012-03-29 TWiki:Main.GertjanVanOosten, gertjan at west dot nl:
         #   Handle common tags, as the text may contain variables etc. that need
         #   to be expanded before generating the TOC for another topic.
         $text = $this->handleCommonTags( $text, $web, $topic, $meta );
+        $this->{ignoreTOC} = undef;
     }
 
     my $insidePre = 0;

-- TWiki:Main/PeterThoeny - 2013-06-27

ItemTemplate
Summary Support TOC in skin
ReportedBy TWiki:Main.PeterThoeny
Codebase ~twiki4, 5.1.4
SVN Range TWiki-5.1.3-trunk, Tue, 04 Jun 2013, build 25988
AppliesTo Engine
Component

Priority Normal
CurrentState Closed
WaitingFor

Checkins TWikirev:26021 TWikirev:26022
TargetRelease major
ReleasedIn 6.0.0
Edit | Attach | Watch | Print version | History: r8 < r7 < r6 < r5 < r4 | Backlinks | Raw View |  Raw edit | More topic actions
Topic revision: r8 - 2013-10-15 - PeterThoeny
 
This site is powered by the TWiki collaboration platform Powered by PerlCopyright © 2008-2024 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback