cross
New Foswiki release 2.1.6 is available with important security fixes.
Sourceforge foswiki email lists being discontinued. Subscribe to the new Foswiki announce and discuss lists at MailingLists
This question about Topic Markup Language and applications: Task filed

Is it possible to use TOC in a view_template

I have tried %TOC{ "%BASETOPIC%" }% and variations but can't find a way. Maybe it's not possible because it cannot work with the contents of %TEXT% outside of %TEXT%?

If there is another work-around it would be worth it because I want to (wherever possible) to keep TML/MACROS away from end-user text, they use WYSIWYG.

-- LarsEik - 30 Oct 2009

%TOC{"%BASETOPIC%" web="%BASEWEB%"}% ought to work.

-- CrawfordCurrie - 30 Oct 2009

I really wish it would. On my system it doesn't. If it is not a bug, is it possible to find a 'creative' way to get this?

I have
%TMPL:INCLUDE{"view"}% 
%TMPL:DEF{"form"}%%TMPL:END%
%TMPL:DEF{"content"}%
%TOC{"%BASETOPIC%" web="%BASEWEB%"}%
%TEXT%
..some formfields...
%TMPL:END%

-- LarsEik - 30 Oct 2009

Unfortunately because of the flawed way TOC works, the content of the topic has already been replaced by the content of the view template before it comes to generate the TOC. There's a workaround, but only by hacking the code.
Index: lib/Foswiki.pm
===================================================================
--- lib/Foswiki.pm   (revision 5188)
+++ lib/Foswiki.pm   (working copy)
@@ -1998,7 +1998,7 @@
       || '';
     $title = CGI::span( { class => 'foswikiTocTitle' }, $title ) if ($title);
 
-    if ( $web ne $defaultWeb || $topic ne $defaultTopic ) {
+    if ( 1 || $web ne $defaultWeb || $topic ne $defaultTopic ) {
         unless (
             $this->security->checkAccessPermission(
                 'VIEW', $this->{user}, undef, undef, $topic, $web

However this has potential knock-on effects in several different areas, so can't be recommended.

This needs a follow up; please report it as a bug in Tasks web.

-- CrawfordCurrie - 01 Nov 2009

Foswiki:Tasks.Item2317

I won't hack the core code. I thought maybe there could be a way around using template files instead of template topics but I soon gave up.

-- LarsEik - 01 Nov 2009

As noted in Foswiki:Tasks.Item2317, a simple workaround is to use this in the view template:
%TOC{"%BASETOPIC%" web="%BASEWEB%"}%
%INCLUDE{%BASEWEB%.%BASETOPIC%}%

Using this format, the table of contents will include any headings in both the view template and the base topic.

-- LynnwoodBrown - 27 Jun 2012

QuestionForm edit

Subject Topic Markup Language and applications
Extension
Version Foswiki 1.1.5
Status Task filed
Related Topics Question1110, Tasks.Item2317
Topic revision: r6 - 27 Jun 2012, LynnwoodBrown - This page was cached on 23 Mar 2018 - 05:43.

The copyright of the content on this website is held by the contributing authors, except where stated elsewhere. See Copyright Statement. Creative Commons License