SID-01748: Table of Contents on every topic view
| Status: |
Answered |
TWiki version: |
5.1.1 |
Perl version: |
5.10.0 |
| Category: |
CategoryTemplates |
Server OS: |
SUSE Linux Enterprise Server 11, kernel 3.0.73 |
Last update: |
12 years ago |
I am new to TWiki and have recently successfully migrated my existing corporate IT wiki from
MediaWiki to TWiki as part of a continuous improvement initiative.
MediaWiki has the feature of automatically generating a table of contents for each page. In TWiki I can generate a table of contents for a topic by explicitly adding %TOC% to the topic content.
Is there a way I can have a Table of Contents automatically generated for each topic when viewed without editing the topic to add %TOC%?
I have a custom view template which incorporates the
BreadCrumbsPlugin and
RedirectPlugin. However, adding %TOC% to it does not seem to work. Another possibility that I haven't tried it is to create a custom edit template for new topics which adds the %TOC%.
I have searched for an answer to this but could not find one.
Any advice would be much appreciated.
--
Andrew Benedek - 2013-06-26
Discussion and Answer
In your custom view template, have you tried this?
%TOC{ "%BASETOPIC%" web="%BASEWEB%" depth="3" }%
See details in
VarTOC2.
--
Peter Thoeny - 2013-06-26
Thanks Peter, I tried your suggestion but it didn't work either. My SKIN setting is myskin, tagme, topmenu, pattern.
Below is part of my custom view template:
%TMPL:DEF{"mytoc"}%%TOC{ "%BASETOPIC%" web="%BASEWEB%" depth="3" }%%TMPL:END%
%TMPL:DEF{"contentheader"}%
<div class="tagmetags"> Tags: %TAGME{ tpaction="%URLPARAM{tpaction}%" web="%WEB%" tag="%URLPARAM{tag}%" }%,
view all tags,
search for tags </div>
<div class="patternTop">%TMPL:P{"breadcrumb"}%</div>
<div class="patternTop">%BREADCRUMBS{type="path" separator=" » "}%</div>
<div class="patternTop">%TMPL:P{"redirectedfrom"}%</div>
<div class="patternTop">%TMPL:P{"mytoc"}%</div>
I am here 1
%TMPL:END%
--
Andrew Benedek - 2013-06-27
I checked - there was a bug/optimization that prevented the TOC from working properly if present in a skin. This is now fixed, you need to apply the patch listed at
TWikibug:Item7286
.
--
Peter Thoeny - 2013-06-27
Thanks Peter, much appreciated. Patching using the patch tool failed for me on hunk 4 probably because I did not have the patch for Item6864, but managed to merge it manually. Thanks again.
--
Andrew Benedek - 2013-06-28
I am glad it worked out for you.
--
Peter Thoeny - 2013-06-28
If you answer a question - or someone answered one of your questions - please remember to edit the page and set the status to answered. The status selector is below the edit box.