user fields: accessing and extracting data

189 views
Skip to first unread message

am ibr

unread,
May 13, 2021, 10:24:09 PM5/13/21
to TiddlyWiki
Hello,

I am trying to understand how to use and manipulate the user fields section.
In a tiddler edit mode, at the bottom below "content type", there is a "add a new field" section.

If I add a new field, call it "catalase", and I assign a field value of "xyz", how do I display the value of the field in the body of the tiddler? If I create more than one user field, can I display a list of all field:value pairs in the body of the tiddler ? I am just having difficulty understanding how to manipulate this.

Any help would be appreciated,
A

ps: I am trying to have create a tiddler for each organism I am collecting data on, and those organisms have basic lab reactions. I thought I'd store the basic reactions and their result in fields and be able to extract that information. Is that the right use of the fields ? thanks

Eric Shulman

unread,
May 13, 2021, 10:46:36 PM5/13/21
to TiddlyWiki
On Thursday, May 13, 2021 at 7:24:09 PM UTC-7 ai.gene...@gmail.com wrote:
I am trying to understand how to use and manipulate the user fields section.
In a tiddler edit mode, at the bottom below "content type", there is a "add a new field" section.
If I add a new field, call it "catalase", and I assign a field value of "xyz", how do I display the value of the field in the body of the tiddler?

You can use the $view widget, like this: <$view field="catalase" />  Alternatively, you can use *transclusion* syntax, like this: {{!!catalase}}.  The difference is that the $view widget will display the field value as plain text, while the transclusion syntax will parse the field value as wikitext, so it can contain other formatting syntax within the value of the field,.
 
If I create more than one user field, can I display a list of all field:value pairs in the body of the tiddler ? I am just having difficulty understanding how to manipulate this.

To automatically generate a list of all fields in a tiddler, you can use the $list widget with the fields[] filter operator, like this:

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

Notes:
* The fields[] operator returns ALL fields of the current tiddler, including the standard fields that exist in every tiddler (title, text, tags, created, modified).  The example filter above removes those specific field names so that only your "user" fields are output.
* The example uses the variable="somename" parameter to hold the matching field name so that the <<currentTiddler>> value remains unchanged inside the $list widget.  This is needed so that the $view widget will reference the current tiddler in which the $list widget occurs.

enjoy,
-e

am ibr

unread,
May 13, 2021, 10:56:59 PM5/13/21
to TiddlyWiki
Thank you Eric, that is great, it produces the right results !
I'm seeing some other enhancements I can add (for example turn the field name into a tiddler so the list generated would be something like: [[field name]] = field value ).
Is there a place I can go to read and learn this how to manipulate this? I will start on TW5 and the $list widget.
Thanks again,


Eric Shulman

unread,
May 13, 2021, 11:26:28 PM5/13/21
to TiddlyWiki
On Thursday, May 13, 2021 at 7:56:59 PM UTC-7 ai.gene...@gmail.com wrote:
I'm seeing some other enhancements I can add (for example turn the field name into a tiddler so the list generated would be something like: [[field name]] = field value ).

You can use the $link widget, like this:
<$link to=<<fieldname>>/> = <$view field=<<fieldname>> /><br>

-e

am ibr

unread,
May 13, 2021, 11:27:38 PM5/13/21
to TiddlyWiki
I was JUST implementing it, stumbled on it while reading other material! thanks again Eric !
Reply all
Reply to author
Forward
0 new messages