How to count all items in a dynamically generated list

Considering:

There are 3 tiddlers tagged class/a.
The text field is different for each tiddler.
The search yields all tiddlers searched for.

<$list filter="[tag[class/a]get[text]] +[addsuffix[/]]" variable="prefix">
<$list filter="[prefix<prefix>] +[search:{!!search}] +[count[]]" variable="search-list">
<<search-list>>
</$list></$list>

The result is a total count for each prefix, so in this case 3 results. The results are correct. But I would like to get 1 result with a total count of all prefixes together.

How can I do that?

Trend, carrying a variable accross more than one list widget is a little tricky, I have explored it in the past.

  • The obviouse approach is to make a seperate filter that “lists” all titles including those in the inner list and use count[] however in your example that is all you are doing on the inside list, is to count.
  • Will however revisit this “gap” in tiddlywiki, because I like a chalenge.

Try something along these lines, it is difficult to be precise without understanding the content and structure of the tiddlers involved:

<$list filter="[tag[class/a]get[text]addsuffix[/]] :map:flat[all[tiddlers]prefix<currentTiddler>] :and[search:{!!search}count[]] variable="search-list">
	<<search-list>>
</$list>
1 Like

If this is only returning one value, the count, we may as well as leave the list widget behind?

Total {{{ [tag[class/a]get[text]addsuffix[/]] :map:flat[all[tiddlers]prefix<currentTiddler>] :and[search:{!!search}count[]] }}}

@TW_Tones
@saqimtiaz

Great these solutions work ! Thank you so much.

I don’t understand what is happening here. Could someone explain this part?
I must admit that I am still a little mystified by those filter run prefixes, not sure if I really get it.

Map (and a few of the other filter run prefixes) allow you to take the result of what your filter has built so far (in your case getting the text and adding a suffix) and store it in in a variable (currentTiddler) to be further operated on. In the same way you thought to get your converted string in your first list and then start with that value in an inner list, instead when you add a :map:flat prefix, it does the same thing but all in one filter - it allows you do do prefix<currentTiddler> because currentTiddler is the result of what was fed into :map:flat, just the same way as setting the variable of your outer list.

Aside from the :map:flat setting the currentTiddler variable, note that there are a couple other ones set like ..currentTiddler for what the currentTiddler was before map changed it, index, and length.
https://tiddlywiki.com/#Map%20Filter%20Run%20Prefix

@stobot

That’s actually neat to make simpler better readable filters.
I will take a look at the documentation again with this new knowledge.

Thank you very much.