Apologies for not hammering out the logic myself, but maybe this is a common-enough interest to be usefully documented here:
I’d like to list links under a filter condition, but have each link display conditionally in tag-pill form ({{|| $:/core/ui/TagTemplate }}) if and only if it has “children” tagging it, and in regular tiddlylink form (<$link /> ) otherwise.
I’m guessing this is child’s play for some of you… Would you be willing to share?
Perhaps you could state what you want a little more clearly. I am now at my desk and want to give you full answer but struggling to answer fully as your question is brief and a little short of information. Perhaps tell us under what condition?
I also have no test data and can’t really create it from your description:
What follows is an attempt to second guess your needs.
<$set name=mytiddler value=<<currentTiddler>> >
<$list filter="list condition">
<!-- uses "list condition" and sets currentTiddler variable, to generate a list of tiddlers-->
<$list filter="[all[current]tag<mytiddler>]" emptyMessage="<$link/>" >
{{|| $:/core/ui/TagTemplate }}
<!-- if current tiddler in list tagged by <mytiddler> if not use emptyMessage -->
</$list>
</$list>
</$set>
Gee, I thought the situation was fairly intuitive. Thanks for your replies so far, but I should clarify:
I want to list all tiddlers tagged ‘definitions’ (say), and the list should look just like the familiar list-links EXCEPT that I see a tag pill (in its proper within the alpha-order list) for exactly those items which itself have tag-children.
For example, I have a tiddler for ‘logic’ (tagged definitions) and there are also other subordinate tiddlers tagging ‘logic’ as well. But the definition-tiddler for ‘premise’ is “bottom-level” – it has a definition tag, but nothing tags to it.
I don’t want tag-pills to display for ‘premise’ and other low-level tiddlers in the list, because it’s irksome to see a tag and click on it, and find that there’s nothing there beyond the tiddler itself.
Having tag pills exactly where they “contain” something is a visually clear way of inviting visitors to recognize that there’s “depth” to some of the items, and not to others.
(I think I recall someone somewhere had a nifty way that a tag pill could show the number of tiddlers tagged, right there at the right edge of the tag pill. That would be even better, but my hope is that if the number of items so tagged is zero, then we should see an ordinary link.)
Create a new tiddler in TiddlyWiki.com and give the code below a spin to see if it either of the two lists match what you’re looking for appearance-wise.
The above code is a modified copy of a macro defined in $:/core/macros/tag, and adds the display of $(taggedCount)$ inside the tag pill. Of course, you can then remove the display of <<taggedCount>> from your code.