So far the best way I can find is to simply use a list to generate a fieldname; then choose what todo inside the list;
Literal fieldnames
<$list filter="field1 field2 field3 field4 field5" variable=fieldname>
</$list>
With variable and subfilter
\define field-list() field1 field2 field3 field4 field5
<$list filter="[subfilter<field-list>]" variable=fieldname>
</$list>
Found fields with prefix
<$list filter="[all[current]fields[]prefix[field]]" variable=fieldname>
</$list>
Then within this list you can do many things to <<fieldname>>
s, Insert one or more of the following inside one of the above lists.
List fieldname only if it has a value
<$list filter="[all[current]has<fieldname>then<fieldname>]">
</$list>
List fieldname and value only if it has a value
<$list filter="[all[current]get<fieldname>]" variable=field-value>
<<fieldname>> <<field-value>><br>
</$list>
List values if has value with get
{{{ [all[current]get<fieldname>] }}},
And you can do any other thing you want to test or display, using the current tiddler and <<fieldname>>
or <fieldname>
.
Note:
Nested lists (one inside another) or a list containing a filtered transclusion {{{ filter }}}
is an efficient way to do this despite peoples tendency not to do this. It allows you to name the variable using variable=fieldname
as an example allowing you to still access the current tiddler.
- People seem to “want to write a single list and single filter”, but sometimes this means you need to do a lot of filter “gymnastics” to make it work, but this is totally unnecessary. Just nest lists.
The following is an example of combining one of the lists above with a way to display the result that most resembles the original request.
\define field-list() field1 field2 field3 field4 field5
<$list filter="[subfilter<field-list>]" variable=fieldname>
{{{ [all[current]get<fieldname>] }}},
</$list>
I live in the +10 time zone so did not respond earlier thank @EricShulman