Hi,
yes that is very possible and here is how you would do it:
\define toc-selective-single-expandable(tag,sort:"",itemClassFilter)
<ol class="tc-toc toc-selective-expandable">
<$list filter="[all[shadows+tiddlers]tag[$tag$]!has[draft.of]$sort$]">
<$list filter="[all[current]toc-link[no]]" variable="ignore" emptyMessage="<<toc-linked-selective-single-expandable-body tag:'$tag$' sort:'$sort$' itemClassFilter:'$itemClassFilter$'>>">
<<toc-unlinked-selective-single-expandable-body tag:"""$tag$""" sort:"""$sort$""" itemClassFilter:"""$itemClassFilter$""">>
</$list>
</$list>
</ol>
\end
\define toc-linked-selective-single-expandable-body(tag,sort:"",itemClassFilter)
<$set name="toc-state" value=<<qualify "$:/state/toc/$tag$">>>
<$set name="toc-item-class" filter="""$itemClassFilter$""" value="toc-item-selected" emptyValue="toc-item">
<li class=<<toc-item-class>>>
<$link>
<$list filter="[all[current]tagging[]limit[1]]" variable="ignore" emptyMessage="<$button class='tc-btn-invisible'>{{$:/core/images/blank}}</$button>">
<$reveal type="nomatch" state=<<toc-state>> text=<<currentTiddler>>>
<$button set=<<toc-state>> setTo=<<currentTiddler>> class="tc-btn-invisible">
{{$:/core/images/right-arrow}}
</$button>
</$reveal>
<$reveal type="match" state=<<toc-state>> text=<<currentTiddler>>>
<$button set=<<toc-state>> setTo="x-all-close" class="tc-btn-invisible">
{{$:/core/images/down-arrow}}
</$button>
</$reveal>
</$list>
<<toc-caption>>
</$link>
<$reveal type="match" state=<<toc-state>> text=<<currentTiddler>>>
<$macrocall $name="toc-selective-single-expandable" tag=<<currentTiddler>> sort="""$sort$""" itemClassFilter="""$itemClassFilter$"""/>
</$reveal>
</li>
</$set>
</$set>
\end
\define toc-unlinked-selective-single-expandable-body(tag,sort:"",itemClassFilter)
<$set name="toc-state" value=<<qualify "$:/state/toc/$tag$">>>
<$set name="toc-item-class" filter="""$itemClassFilter$""" value="toc-item-selected" emptyValue="toc-item">
<li class=<<toc-item-class>>>
<$list filter="[all[current]tagging[]limit[1]]" variable="ignore" emptyMessage="<$button class='tc-btn-invisible'>{{$:/core/images/blank}}</$button> <$view field='caption'><$view field='title'/></$view>">
<$reveal type="nomatch" state=<<toc-state>> text=<<currentTiddler>>>
<$button set=<<toc-state>> setTo=<<currentTiddler>> class="tc-btn-invisible">
{{$:/core/images/right-arrow}}
<<toc-caption>>
</$button>
</$reveal>
<$reveal type="match" state=<<toc-state>> text=<<currentTiddler>>>
<$button set=<<toc-state>> setTo="close" class="tc-btn-invisible">
{{$:/core/images/down-arrow}}
<<toc-caption>>
</$button>
</$reveal>
</$list>
<$reveal type="match" state=<<toc-state>> text=<<currentTiddler>>>
<$macrocall $name="""toc-selective-single-expandable""" tag=<<currentTiddler>> sort="""$sort$""" itemClassFilter="""$itemClassFilter$"""/>
</$reveal>
</li>
</$set>
</$set>
\end
Copy and append this
either in $:/core/macros/toc or make a new tiddler
copy this into it and tag it $:/tags/Macro. Then use it with:
<<toc-selective-single-expandable 'TableOfContents'>>
Alternatively you can
just drag&drop the attached file and import the tiddlers.
/Andreas
--
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 tiddlywiki+...@googlegroups.com.
To post to this group, send email to tiddl...@googlegroups.com.
Visit this group at http://groups.google.com/group/tiddlywiki.
For more options, visit https://groups.google.com/d/optout.
A follow-up question. TOC get sorted by the "title" but I would like to sort it by "caption ". Where do I put that in the code?
<<toc-selective-single-expandable "TableOfContents" "sort[caption]">><<toc-selective-single-expandable "TableOfContents" "sort[title]sort[caption]">>You could sort by title first and then caption, in case there was no caption...
Am I wrong, or does this at most result in the tiddlers with an empty caption being sorted alphabetically by title ? And even that might not be guaranteed by the TW sort algorithm. So what would be the advantage to sort it by title first ? (It does not produce a perfectly sorted output, does it ?)