<$list filter="[all[current]tag[TableOfContents]]" variable="null">
<h3>Contents</h3>
<div class="tc-table-of-contents">
<$macrocall $name="toc-selective-expandable" tag=<<currentTiddler>>/>
</div>
</$list><$list filter="[all[current]tag[with-toc]]" variable="null">
<$set name="sectionTitle" value={{!!contents_title}} emptyValue="Projects">
<h3><<sectionTitle>></h3>
</$set>
<div class="tc-table-of-contents">
<$macrocall $name="toc-selective-expandable" tag=<<currentTiddler>>/>
</div>
</$list>\define default-toc-here()
<h4>Optional TOC here</h4>
<$list filter="[tag<currentTiddler>limit[1]]" emptyMessage="//nothing tagged with <<currentTiddler>>//" variable=nul >
<$macrocall $name="toc-selective-expandable" tag=<<currentTiddler>> >
</$list>
\end
<$list filter="[all[current]has:field[toc-here]]" variable=nul>
<$list filter="[all[current]get[toc-here]]" variable=toc-tiddler emptyMessage=<<default-toc-here>> >
<h4>Optional TOC <<toc-tiddler>></h4>
<$macrocall $name="toc-selective-expandable" tag=<<toc-tiddler>> >
</$list>
</$list>How one can set the order of elements added to a tiddler through ViewTemplates?
Hi Tony,How one can set the order of elements added to a tiddler through ViewTemplates?
Folks,I have another approach, test this on TiddlyWiki.comCreate a tiddler containing this and tag with $:/tags/ViewTemplate\define default-toc-here()
<h4>Optional TOC here</h4>
<$list filter="[tag<currentTiddler>limit[1]]" emptyMessage="//nothing tagged with <<currentTiddler>>//" variable=nul >
<$macrocall $name="toc-selective-expandable" tag=<<currentTiddler>> >
</$list>
\end
<$list filter="[all[current]has:field[toc-here]]" variable=nul>
<$list filter="[all[current]get[toc-here]]" variable=toc-tiddler emptyMessage=<<default-toc-here>> >
<h4>Optional TOC <<toc-tiddler>></h4>
<$macrocall $name="toc-selective-expandable" tag=<<toc-tiddler>> >
</$list>
</$list>
- Nothing will happen right away.
- Now add the field toc-here to any tiddler and it will provide a toc based on the current tiddler. Use new here to add items to its toc
- If however you give that field a value of tiddlername eg HelloThere then the tiddlername will be used as the root of the TOC
Advantages of this approach
- No additional tag use
- Ability to reference other parts of a TOC
Choose wisely so if others do the same it remains valid.
I tend to list before or after the body
Or after the subtitle
Tony