playing around with a copy of TagTemplate, and trying to get a tag pill to display a count of the number of tiddlers with said tag

83 views
Skip to first unread message

Elijah

unread,
Jan 6, 2019, 12:40:34 PM1/6/19
to TiddlyWiki
There is a little bit in TagTemplate: tag=<<currentTiddler>>, which tells the tag-pill what to display. With the default <<currentTiddler>>, it will display the title of the tiddler corresponding to the tag. With {{!!caption}} it'll display the contents of the caption-field of the tag-tiddler.

Now, I'm trying to figure out how to get the tag-pill to instead display the number of tiddlers tagged with some specific tag. I thought {{{[tag[<<currentTiddler>>]count[]]}}} would work, but it doesn't - it simply displays "0". However, if you manually-input the title of the tag in the same filter as follows: {{{[tag[ACTUALTAG]count[]]}}}, it displays the correct count. I admit I don't understand how the filter-operators work, or even how to correctly call them (the documentation (specifically Filter Operators, count Operator, and count Operator (Examples)) was unhelpful to me), and I got the {{{[tag[ACTUALTAG]count[]]}}} from Tobias Beer's tiddlywiki. Any help would be appreciated. Thanks.

Brian Theado

unread,
Jan 6, 2019, 2:59:00 PM1/6/19
to tiddl...@googlegroups.com
When using variables as a filter parameter, the syntax is different from what you are attempting. Try {{{[tag<currentTiddler>count[]]}}}


On Sun, Jan 6, 2019 at 12:40 PM Elijah <elija...@gmail.com> wrote:
There is a little bit in TagTemplate: tag=<<currentTiddler>>, which tells the tag-pill what to display. With the default <<currentTiddler>>, it will display the title of the tiddler corresponding to the tag. With {{!!caption}} it'll display the contents of the caption-field of the tag-tiddler.

Now, I'm trying to figure out how to get the tag-pill to instead display the number of tiddlers tagged with some specific tag. I thought {{{[tag[<<currentTiddler>>]count[]]}}} would work, but it doesn't - it simply displays "0". However, if you manually-input the title of the tag in the same filter as follows: {{{[tag[ACTUALTAG]count[]]}}}, it displays the correct count. I admit I don't understand how the filter-operators work, or even how to correctly call them (the documentation (specifically Filter Operators, count Operator, and count Operator (Examples)) was unhelpful to me), and I got the {{{[tag[ACTUALTAG]count[]]}}} from Tobias Beer's tiddlywiki. Any help would be appreciated. Thanks.

--
You received this message because you are subscribed to the Google Groups "TiddlyWiki" group.
To unsubscribe from this group and stop receiving emails from it, send an email to tiddlywiki+...@googlegroups.com.
To post to this group, send email to tiddl...@googlegroups.com.
Visit this group at https://groups.google.com/group/tiddlywiki.
To view this discussion on the web visit https://groups.google.com/d/msgid/tiddlywiki/450ee4a9-b7f1-4132-984e-72298540a3a6%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Elijah

unread,
Jan 6, 2019, 3:09:52 PM1/6/19
to tiddl...@googlegroups.com
That's it. Thanks.

S. S.

unread,
Jan 7, 2019, 12:09:46 AM1/7/19
to TiddlyWiki

I don't know if you'll find this helpful, but I use a small macro - that I use to put in the caption field of Table of Content Tiddlers, and also use above lists based on a tag.

Tiddler name (example): $:/_macro/count-tag
Tiddler must be tagged: $:/tags/Macro

\define count-tag(tag-name)
<$count filter="[tag[$tag-name$]]"></$count>
\end

The macro <<count-tag MyTagName>> ` is useful in places such as:
  • A summary above a list based on a single tag, Example:
    • This list contains <<count-tag MyTagName>> tiddlers tagged with <<tag MyTagName>>
  • The caption field of a Table of Contents tiddler, where it can be used to display the number of tiddlers that will be found under that link. Example, the caption field contains:
    • My Tag Name ^^(<<count-tag MyTagName>>)^^

Of course it can also be used within a tiddler whose title is the tag in this way:  <$macrocall $name="count-tag" tag-name={{!!title}}/> :but then it is simpler to just use the $count widget: <$count filter="[tag<currentTiddler>]"/>


Regards

Reply all
Reply to author
Forward
0 new messages