\define all()
<$list filter="[tag[foo]]">
<$list filter="[tag{!!title}]">
</$list>
</$list>
\end
<$set name=a value=<<all>>>
{{{ [enlist<a>nth[3]] }}}
</$set>
Possibly by using some form of Wikify instead of Set.
I expect Eric or Jeremy could answer this in a moment but the fact we three, Mat, Mark S and TonyM struggle with it for get newby's
On Monday, 18 May 2020 07:38:33 UTC+10, Mat wrote:
Mark S. wrote:Possibly by using some form of Wikify instead of Set.
\define all()
<$list filter="[tag[foo]]">
<$list filter="[tag{!!title}]">
<$text text="[["/><$text text=<<currentTiddler>>/><$text text="]]"/><br>
</$list>
</$list>
\end
<$wikify name="a" text=<<all>>>
{{{ [enlist<a>nth[3]] }}}
</$wikify>
Maybe my OP is overgeneralizing though. This describes my actual problem if it changes anything:
The tiddlers in the inner listwidget have a number field, e.g "number:7"
I want to calculate the average of the all the numbers, i.e add up all the number fields and also count how many tiddlers there are that are tagged with any of the parent tags.
\define all()
<$list filter="[tag[Foo]]">
<$list filter="[tag{!!title}]">
{{!!number}}
</$list>
</$list>
\end
<$wikify name="a" text=<<all>>>
<$vars total={{{ [enlist<a>sum[]] }}} count={{{ [enlist<a>count[]] }}}>
total=<$text text=<<total>> />
count=<$text text=<<count>> />
average=<$text text={{{ [<total>divide<count>] }}} />
</$vars>
</$wikify>
and, here's a solution to the more specific use-case (gather "number" field values and calculate average)
\define all()
<$list filter="[tag[Foo]]">
<$list filter="[tag{!!title}]">
{{!!number}}
</$list>
</$list>
\end
<$wikify name="a" text=<<all>>>
<$vars total={{{ [enlist<a>sum[]] }}} count={{{ [enlist<a>count[]] }}}>
total=<$text text=<<total>> />
count=<$text text=<<count>> />
average=<$text text={{{ [<total>divide<count>] }}} />
</$vars>
</$wikify>