It's also possible to make the code navigate through an entire TOC, like
this:
\define toc-list(here,max,exclude,level:"1")
<!-- SHOW ALL TOC TIDDLER TITLES AS A FLAT LIST (SIMPLE RECURSION) -->
<$list filter="""[tag[$here$]] $exclude$ -[[$here$]]""">
<$text text="[["/><<currentTiddler>><$text text="]]"/><br>
<$reveal default="$level$" type="nomatch" text="$max$">
<$macrocall $name="toc-list" here=<<currentTiddler>> max="$max$"
exclude="""$exclude$ -[[$here$]]""" level={{{ [[$level$]add[1]] }}}/>
</$reveal>
</$list>
\end
<$wikify name="toc-pages" text=<<toc-list "Index">>>
<$list filter="[enlist<toc-pages>] +[<currentTiddler>]">
<div style="float:right;">
<$vars prev={{{ [enlist<toc-pages>before<currentTiddler>] }}}>
<$vars next={{{ [enlist<toc-pages>after<currentTiddler>] }}}>
<$reveal default=<<prev>> type="nomatch" text="">
<$button tooltip=<<prev>>> {{$:/core/images/chevron-left}}
<$action-sendmessage $message="tm-close-tiddler" param=<<
currentTiddler>> />
<$action-navigate $to=<<prev>>/>
</$button>
</$reveal>
<$reveal default=<<next>> type="nomatch" text="">
<$button tooltip=<<next>>> {{$:/core/images/chevron-right}}
<$action-sendmessage $message="tm-close-tiddler" param=<<
currentTiddler>> />
<$action-navigate $to=<<next>>/>
</$button>
</$reveal>
</$vars>
</$vars>
</div>
</$list>
</$wikify>
The above code does the following:
1) $wikify invokes the <<toc-list>> macro to do a *recursive tree walk*
from the starting tag (in this case "Index"), and converts that output into
a "flat list" of all tiddlers in the tree (<<toc-pages>>)
2) The first filter checks to see if the currentTiddler is in the list of
<<toc-pages>>
3) The prev/next filters use the <<toc-pages>> to find the
before<currentTiddler> and after<currentTiddler>
The rest of the code is still the same as before.
Note:
If there is a particularly large number of items in the TOC, then
performance can be a bit slower.
This is because the entire list has to be computed each time a tiddler is
displayed in order to
determine if that tiddler is actually in the list. Thus, *every* tiddler
gets the added overhead.
Even so, I tested this with Bob Jansen's posted TW document, which has
several hundreds of
TOC entries, and it still performed adequately, though with a very minor
noticeable delay in
rendering tiddlers.
enjoy,
-e
--
You received this message because you are subscribed to the Google Groups
"TiddlyWiki" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/tiddlywiki/23e797a1-b758-43bf-8078-1d232c59ef60o%40googlegroups.com.