This sounds like a job for… macro recursion!
Let’s assume you have a set of “failure” tiddlers, where each tiddler is tagged with “failure
”, and has a field name causes
, which contains a list of other failure tiddler titles. Something like this:
- failure1: causes=“failure2”
- failure2: causes=“failure3 failure4” (i.e., two different causes)
- failure3: causes=“failure5”
- failure4: causes=“failure6”
- failure5: causes=“failure7”
- failure6: causes=“failure7”
- failure7: causes="" (blank field value or omit the field entirely)
First, create a tiddler (e.g., “ShowCausesTemplate”), tagged with $:/tags/ViewTemplate
, containing:
\define showCauses()
<$link/>
<$list filter="[<currentTiddler>get[causes]enlist-input[]]">
<blockquote><$macrocall $name="showCauses"/></blockquote>
</$list>
\end
<$list filter="[<currentTiddler>tag[failure]]"><<showCauses>></$list>
Notes:
-
$:/tags/ViewTemplate
causes the above wikitext content to be invoked for EVERY tiddler
- But the
$list
widget at the end of the tiddler checks to see if the current tiddler is tagged with failure
, so that the <<showCauses>>
macro is only processed for tiddlers that are actually ‘failure’ tiddlers.
- Within the
<<showCauses>>
macro:
- The
$link
widget shows the name of the current tiddler in the chain
- The
$list
widget loops through each “cause” listed in the current tiddler
-
<blockquote>...</blockquote>
provides indentation for showing each step in the chain
- The
$macrocall
does the recursion for each “cause”
The resulting output for tiddler “failure1” will look something like this:
failure1
| failure2
| | failure3
| | | failure5
| | | | failure7
| | failure4
| | | failure6
| | | | failure7
Hope this meets your needs… let me know how it goes.
enjoy,
-e