[tw5] Anyone know how I can expand on filters?

Does anyone know how I can expand on this? I am trying to include multiple fields in this filter.


<ul>
<$list filter="[<currentTiddler>fields[]prefix[FIELDNAME]]" variable="thisfield">
<li><$transclude field=<<thisfield>>/></li>
</$list>
</ul>

What I really would like to do is something like this:


<ul>
<$list filter="[<currentTiddler>fields[]prefix[FIELDNAME]]" variable="thisfield">
<li><$transclude field=<<thisfield>>/>
\variable 2
\variable 3
\variable 4 - also, one of these needs to be a link.
</li>
</$list>
</ul>

What I really would like to do is something like this:


<ul>
<$list filter="[<currentTiddler>fields[]prefix[FIELDNAME]]" variable="thisfield">
<li><$transclude field=<<thisfield>>/>
\variable 2
\variable 3
\variable 4 - also, one of these needs to be a link.

Where should these variables come from? You can use $set, $let widget outside the UL or $list element
-m

The other variables come from other fields. I tried to write something like this:


<ul>
<$list filter="[<currentTiddler>fields[]prefix[PREFIX1]]" variable="variable1">
<li><$transclude field=<<variable1>>/>
<$list filter="[<currentTiddler>fields[]prefix[PREFIX2]]" variable="variable2">
<$transclude field=<<variable2>>/>
<$list filter="[<currentTiddler>fields[]prefix[PREFIX3]]" variable="variable3">
<$transclude field=<<variable3>>/>
<$list filter="[<currentTiddler>fields[]prefix[PREFIX4]]" variable="variable4">
<$transclude field=<<variable4>>/>
</$list>
</$list>
</$list>
</li>
</$list>
</ul>

Variables 2, 3, and 4 are repeated each time the filters are used.

This is a case where it would be helpful to know why you’re doing what you’re doing.

You’re currently using a prefix of a field to turn into a variable which then gets used to find a field value. But you could just extract the field directly:

{{{ [<currentTiddler>fields[]prefix[myfield]nth[1]]:map[<..currentTiddler>get<currentTiddler>] }}}

Where nth[1] can be incremented for each field value you need.

As I wrote in the other post. Wikitext is no general purpose programming language. In wikitext variables are only accessible “inside” a widget “body”. So eg:

<$let var1=test>
<!-- this is the widget body of the let-widget -->

value of var1: <<var1>>

</let>

outside value of var1: <<var1>> <-- there is no var1 any more ... It's gone

So even if you try to nest the list-widget, it won’t work that way, since your variables are only useful in the inside of the most inner list. … BUT every “outer” list is still active.

So if your variable1 has eg: 2 elements all the inner list will be evaluated 2 times. … That’s what you see.

As I also wrote, in the other post. I don’t see the whole picture, so I could only help with the topic that you described. … But I kind of knew, what could happen. …

We can only help, with problems we know, if they are described in plain text. If we understand the problem we can probably tell you, how to do it the “TiddlyWiki way”. …

The TW UI is mainly created using lists. They are everywhere. … But it’s important to understand that you can’t run a list-widget to create several variables. … You can use list-widgets to iterate over arrays of titles.

It’s like a “map()” function in other languages.

I don’t know, if that helps. … But without the “big picture” we can’t do much.

-mario

There is a typo in the example above: the end-let needs to look like </$let>

<$let var1=test>
<!-- this is the widget body of the let-widget -->

value of var1: <<var1>>

</$let>

outside value of var1: <<var1>> <-- there is no var1 any more ... It's gone

-m
PS: You should post at talk.tiddlywiki.org … We can edit posts there, to be sure examples work