I have been using TiddlyWiki 5 for a few years now, and I have always used a hierarchal structure of tags. I am now coming to the point where I have enough sub-levels of tags, it feels like I have to scroll more horizontally than vertically.
One of the things I really like about TiddlyWiki is that tags can be just another level of tiddlers, and I would quite like to retain that ability to click on a tag and jump to the parent tiddler right away. Unfortunately, this system has resulted in an ungainly table of contents.
I would like to ask if there is any way to hide or deactivate parts of the right bar table of contents after a certain level, or hide certain tags specifically.
For example, if my TOC looked like this:
Item 1
Subitem 1
Extra 1
Extra 2
Extra 3
Item 2
Subitem 2
Item 3
Subitem 3
And so on.
Would there be a way to hide the list under Section 1, so instead my TOC looked like this:
Item 1
Subitem 1
Item 2
Subitem 2
Item 3
Subitem 3
Would something like this be doable?
Thank you.
<div class="tc-table-of-contents">
<<toc-selective-expandable "Contents" exclude: "-[tag[Tag1]]-[tag[Tag2]]">>
</div><div class="tc-table-of-contents">
<<toc-selective-expandable "Contents" sort:"!tag[Tag1]!tag[Tag2]">>
</div>It turns out there is an undocumented "exclude" option, so if you can try that method if you want and see if it works better.
\define toc-linked-selective-expandable-body(tag,sort:"",itemClassFilter:" ",exclude,path,prune:"")
<$set name="toc-state" value=<<qualify """$:/state/toc$path$-$(currentTiddler)$""">>>
<$set name="toc-item-class" filter="""$itemClassFilter$""" emptyValue="toc-item" value="toc-item-selected" >
<$set name="prune" value="""$prune$""">
<li class=<<toc-item-class>>>
<$link>
<$list filter="[all[current]] -[enlist<prune>] +[tagging[]limit[1]]" variable="ignore" scratch="-[enlist<prune>]" emptyMessage="<$button class='tc-btn-invisible'>{{$:/core/images/blank}}</$button>">
<$reveal type="nomatch" state=<<toc-state>> text="open">
<$button set=<<toc-state>> setTo="open" class="tc-btn-invisible tc-popup-keep">
{{$:/core/images/right-arrow}}
</$button>
</$reveal>
<$reveal type="match" state=<<toc-state>> text="open">
<$button set=<<toc-state>> setTo="close" class="tc-btn-invisible tc-popup-keep">
{{$:/core/images/down-arrow}}
</$button>
</$reveal>
</$list>
<<toc-caption>>
</$link>
<$reveal type="match" state=<<toc-state>> text="open">
<$macrocall $name="toc-selective-expandable" tag=<<currentTiddler>> sort="""$sort$""" itemClassFilter="""$itemClassFilter$""" exclude="""$exclude$""" path="""$path$""" prune="""$prune$"""/>
</$reveal>
</li>
</$set>
</$set>
</$set>
\end
\define toc-selective-expandable-empty-message()
<<toc-linked-selective-expandable-body tag:"""$(tag)$""" sort:"""$(sort)$""" itemClassFilter:"""$(itemClassFilter)$""" exclude:"""$(excluded)$""" path:"""$(path)$""" prune:"""$(prune)$""">>
\end
\define toc-selective-expandable(tag,sort:"",itemClassFilter,exclude,path,prune)
<$vars tag="""$tag$""" sort="""$sort$""" itemClassFilter="""$itemClassFilter$""" excluded="""$exclude$ -[[$tag$]]""" path="""$path$/$tag$""" prune="""$prune$""" >
<ol class="tc-toc toc-selective-expandable">
<$list filter="""[all[shadows+tiddlers]tag[$tag$]!has[draft.of]$sort$] -[[$tag$]] $exclude$""">
<$list filter="[all[current]toc-link[no]]" variable="ignore" emptyMessage=<<toc-selective-expandable-empty-message>> >
<$macrocall $name=toc-unlinked-selective-expandable-body tag="""$tag$""" sort="""$sort$""" itemClassFilter="""$itemClassFilter$""" exclude=<<excluded>> path=<<path>> prune="""$prune$""" >
</$list>
</$list>
</ol>
</$vars>
\end
<div class="tc-table-of-contents">
<<toc-selective-expandable "TableOfContents" prune:"Learning [[Drag and Drop]]">>
</div>barro, I am sorry, but could I ask two more questions?
First, how exactly would I write the table of contents to include multiple tags? Like this:<<toc-selective-expandable "Contents" exclude:"-[tag[Tag1][Tag2][Tag3]]">>
Second, after removing the items listed beneath, my TOC headers still show the expandable arrows, though they no longer do anything. How might I get rid of these?
The questions discussed here with toc and filtered tocs etc... Is all about heirachies represented in tiddlywiki. Out of the box tiddlywiki handles this very well.
There are a number of threads here that cover this and extending functionality like the exclude tiddlers.
I can recomend playing with and building your own toc macro because its a great way to learn about recursion ie call a macro that calls a second macro that calls itself. and of course you can customise it. True avoiding infinite loops may be nessasary if your data was not structured.
I am posting here, as heirachical organisation and going beyond simple heirachies, is an interest of mine. I intend to build some grand solutions based on this in time, but you can expect a trickle of macros.
I see the ability to increment a variable to count how deep in the heirachy is an importiant feature we need.
Otherwise I want sophisticated solutions that will ultimately meet most user requirements in a simplified way, potentialy hiding the real complexity.
I am allways open to collaboration.
Regards
Tony
\define toc-levels(root-tiddler max)
<$set name=level value="1">
<$set name=max value="$max$" emptyValue="100">
<blockquote>
$root-tiddler$ (Max levels deep <<max>>)<br>
<$list filter="[tag[$root-tiddler$]]" variable=name>
<$macrocall $name=loopme tiddlername=<<name>> level=<<level>> max=<<max>>/><br>
</$list>
</blockquote>
</$set></$set>
\end
\define loopme(tiddlername level max)
<blockquote>
<h$level$>$level$. <$link to="$tiddlername$" tooltip="Click to open $tiddlername$"><$view tiddler="$tiddlername$" field="caption" format=text><$view tiddler="$tiddlername$" field="title" format=text></$view></$view></$link></h$level$>
<$formula-vars
next-level=add($level$,1)>
<$list filter="[[$max$]] -[[$level$]]">
<$list filter="[tag[$tiddlername$]]" variable=loop-name>
<$macrocall $name="loopme" tiddlername=<<loop-name>> level=<<next-level>> max="$max$"/>
</$list>
</$list>
</$formula-vars>
</blockquote>
\end
<<toc-levels TableOfContents 3>>I have been using TiddlyWiki 5 for a few years now, and I have always used a hierarchal structure of tags. I am now coming to the point where I have enough sub-levels of tags, it feels like I have to scroll more horizontally than vertically.
One of the things I really like about TiddlyWiki is that tags can be just another level of tiddlers, and I would quite like to retain that ability to click on a tag and jump to the parent tiddler right away. Unfortunately, this system has resulted in an ungainly table of contents.
I would like to ask if there is any way to hide or deactivate parts of the right bar table of contents after a certain level, or hide certain tags specifically.
For example, if my TOC looked like this:
Item 1
Subitem 1
Extra 1
Extra 2
Extra 3
Item 2
Subitem 2
Item 3
Subitem 3
And so on.
Would there be a way to hide the list under Section 1, so instead my TOC looked like this:
Item 1
Subitem 1
Item 2
Subitem 2
Item 3
Subitem 3
Would something like this be doable?
Thank you.