1

Using TiddlyWiki, I'm trying to show, in a specific Tiddler, a subset of all the fields of that tiddler, with their values.

The problem is, while I'm able to list all the relevant fields' names, I cannot print their value.

My current code is:

<$list filter="[fields[]prefix[Result_]sort[title]]"  template="$:/zx/ListFieldItemTemplate"/>

... which aims to list all the fields starting with Result_.

The (simplified) template $:/zx/ListFieldItemTemplate is:

<div>
    <$view field="title"/>
</div>

My fear is that the list widget is only sending the names of the fields, not the values, which means there's no way to get that value from the template. So I may need to somehow send the values, too. But I don't know how.

paercebal
  • 81,378
  • 38
  • 130
  • 159

2 Answers2

2

One possibility is to use a macro.

In your tiddler, put the following macro call:

<<myMacro prefix:"Result_">>

(The aim is to filter the fields only to those starting with "Result_".)

Then, create a new tiddler, whose name is not important, but which must contain the tag $:/tags/Macro to make that macro globally available. And in that tiddler, write the following code:

\define myMacro(prefix:"")
<$list filter="[fields[]prefix[$prefix$]sort[title]]" variable="fieldName">
<<fieldName>>
====
<$view field=<<fieldName>>/>
</$list>
\end

This will output something like:

Result_MyFieldName1 ==== MyFieldValue1
Result_MyFieldName2 ==== MyFieldValue2
Result_MyFieldName3 ==== MyFieldValue3
Result_MyFieldName4 ==== MyFieldValue4

Of course, you can then modify the macro to use your own formatting.

paercebal
  • 81,378
  • 38
  • 130
  • 159
1

This is an old thread, but maybe someone will find this useful:

Loop through all fields and list name/value:

<$list filter="[fields[]] -[[title]] -[[text]] -[[tags]] -[[created]] -[[modified]]" variable="fieldname"> <> = <$view field=<> />
</$list>

MAK
  • 31
  • 4