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
..some formfields...

-- 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/
--- lib/   (revision 5188)
+++ lib/   (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 (
                 '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


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:

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
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 20 Mar 2019 - 09:30.

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