Let’s say I have several tiddlers tagged “Person”. Each Person can have several Tasks, each one a tiddler with several tags, one of them “Task” and one of them the name of the person. Now I want to have a list of all Tasks and list the person name tag in front of each task description. The following code will list all tags for each task.
<$list filter="[tag[Task]]">
<div class="tc-tags-wrapper">
<!-- How to filter the tag list here? -->
<$list filter="[all[current]tags[]]"
template="$:/core/ui/TagTemplate"
storyview="pop" />
</div>
<<currentTiddler>>
</$list>
In plain English my filter criterion for tags[] would read: “if a Tiddler with the tag title exists AND that tiddler is tagged ‘Person’”
Probably what comes back from tags[] is not a list of tiddlers but a list of strings or tag objects and I need to turn then back to tiddlers to filter them further. Is that mental model correct?
<$list filter="[tag[Task]]">
<div class="tc-tags-wrapper">
<!-- How to filter the tag list here? -->
<$list filter="[all[current]tags[]tag[Person]]"
template="$:/core/ui/TagTemplate"
storyview="pop" />
</div>
<<currentTiddler>>
</$list>
I have found two solutions to my problem, one using tags[] and one using different lists:
<$list filter="[tag[Task]]">
<div class="tc-tags-wrapper">
<$list filter="[all[current]tags[]]" variable=tagName>
<!-- TODO can this 3rd list level somehow be folded into the filter above? -->
<$list filter="[<tagName>tag[Person]]"
template="$:/core/ui/TagTemplate"
storyview="pop"
/>
</$list>
</div>
<<currentTiddler>>
</$list>
The third nested list converts the tag name back to a tiddler. I wonder if that nested list structure could be optimized while still using tags[]?
Another option is a different list nesting and rendering the person tiddler with the tag template:
<$list filter="[tag[Person]]" variable=personT>
<div class="tc-tags-wrapper">
<$list filter="[tag<personT>tag[Task]]">
<!-- TODO find out how to use $:/core/ui/TagTemplate directly -->
<span class="tc-tag-label"
style="background-color:; fill:#333333; color:#333333;">
<$link to=<<personT>>/>
</span>
</$list>
</div>
<<currentTiddler>>
</$list>
I could not figure out how to transclude $:/core/ui/TagTemplate with ´personT´ as the current tiddler, so I took some styles from the template to at least have the pill appearance of the tags.