How to write a value in a field without using $action-setfield?

Hi TW-Experts,

I have a multilanguage TW in place and we are using the solution from @FRDV provided here Field selection by $:/language - Discussion - Talk TW

this is working well so far.

Additionally I am using the solution from @Scott_Sauyet to display the caption instead of the tittle, if available. Display the caption field instead of the tiddler title in story line - Discussion - Talk TW

Now we want to have the possibility to display also the caption, and the author field form the tiddler that is displayed. Actually, only the content of the language specific tiddler will be displayed but the caption/title and author information from the tiddler.

So far as I was able to understand is there the possibility to use $action-setfield to write something into a field. But in this use case there is no action like a button or similar.

Is there a solution available I was not able to understand?

Thx in advance
Stefan (an old assembler developer who is struggling with the new concepts but willing to learn)

I’m sorry, but I cannot make sense of this. Could you try to reword it and/or give an example?

Not by default. All the action-widgets need a manual trigger. Mainly from buttons or link-clicks.

I did create a “trigger-widget” that will be triggered as soon as it is displayed. But you need to use it carefully, since it is able to trigger endless loops if used carelessly. See: Trigger — an interactive test framework

Eg:

BACKUP FIRST – BACKUP FIRST – BACKUP FIRST

title: New Tiddler
caption: my caption

\define test-tiddler() test-tiddler

\define test(msg)
<$action-setfield $tiddler=<<test-tiddler>> $field=text $value={{{ [{!!caption}format:titlelist[]] }}}/>
<$action-navigate $to=<<test-tiddler>>/>
\end

<$trigger actions=<<test>>/>

<pre><$view/></pre>

Hi @Scott_Sauyet,

sorry for the delayed reply.
I developed a simple example:

author: This is a placeholder
de-DE: Org-Ge
en-GB: Org-En
title: Org

<$list filter="[{$:/language}] +[removeprefix[$:/languages/]]" variable="selected-language">
<$list filter="[<currentTiddler>has<selected-language>get<selected-language>]"  emptyMessage="no translation for {{$:/language}}" variable="thislanguage" ><$transclude tiddler=<<thislanguage>> mode="block" />
</$list>
</$list>
author: The Team from Germany
caption: Die Organisation
title: Org-Ge

Hier wird die Organisation vorgestellt
author: The US Team
caption: The Organization
title: Org-En

The organization is introduced here

The user of the wiki will only see the tiddler Org and based on the language setting the text from Org-Ge or Org-En will be displayed.

But if you look to the screeshot you will see also that the caption and the author fields will remain from the Org tiddler.

image

I hope this will describe my situation better.

Thx in advance for any support
Stefan

The TW UI templates do not handle any author field. So I assume, that you use a custom template to display an author field.

TW transclusions do have a “special” behaviour. If they do not find the $tiddler or $field value, they show the body of the transclusion.

So if you transclude the author field like this:
<$transclude $field="author"><$transclude $tiddler=xxx $field="author"/></$transclude>

If the currentTiddler author field is empty, it will show the author field of tiddler “xxx”. So you only need to create the right filter for xxx in your template, depending on the selected language.

So no modification of tiddler fields should be needed.

Hi @pmario,

yes you are right. I miss to provide this tiddler I am using also:

tags: $:/tags/ViewTemplate/Subtitle
title: $:/core/ui/ViewTemplate/subtitle/modifier

<$link to={{{[all[current]has[author]get[author]] :else[get[modifier]] }}}/>

I am not sure where to add your code. This here is not working as expected, but I think the failure is on my side.

<$list filter="[{$:/language}] +[removeprefix[$:/languages/]]" variable="selected-language">
<$list filter="[<currentTiddler>has<selected-language>get<selected-language>]"  emptyMessage="no translation for {{$:/language}}" variable="thislanguage" ><$transclude tiddler=<<thislanguage>> mode="block" />

<$transclude $field="author"><$transclude $tiddler=<<thislanguage>> $field="author"/></$transclude>

</$list>
</$list>

Stefan

I think if you change your $:/core/ui/ViewTemplate/subtitle/modifier to something like the following, it should work:

<$list filter="[{$:/language}] +[removeprefix[$:/languages/]]" variable="selected-language">
<$link to={{{[<currentTiddler>has<selected-language>get<selected-language>has[author]get[author]] :else[<currentTiddler>has[author]get[author]] :else[get[modifier]] }}}/>
</$list>

You can download this and drag the resulting file to tiddlywiki.com or an empty wiki to test:
Org_Demo.json (1.9 KB)

@Scott_Sauyet

Thank you so much. I have some Ideas to use this possibility also for other fields.

Hi @Scott_Sauyet, @pmario,

I am trying to use the same procedure to exchange the caption also but thsi seems to be much more difficult.

  1. If the language specific field contains a tiddler the title of this tiddler should be shown as title
  2. If the the tiddler in (1.) has a field caption the content of this should be displayed
  3. If there is no language specific field available and the tiddler has a field caption this content should be displayed
  4. I not 1, 2 or 3 the title should be displayed.

I tried this her what is working well but not in Situation 4 or if the field caption contain a transcluding itself like Welcome to this {{NameOfThisTool}}

title: $:/core/ui/ViewTemplate/title/default

\whitespace trim
<h2 class="tc-title">
<$list filter="[{$:/language}] +[removeprefix[$:/languages/]]" variable="selected-language">
<$link to={{{[<currentTiddler>has<selected-language>get<selected-language>has[caption]get[caption]] :else[<currentTiddler>has[caption]get[caption]] :else[get[title]] }}}/>
</$list>
</h2>

Could you please help me to understand my problem?

Thx in advance
Stefan

I don’t at all mind looking at it when I have time, but that’s likely not going to happen for a few days, as I have commitments the next three evenings and rarely have time lately during the workday.

But if you need to include {{NameOfThisTool}} you might need to add a call to wikify, probably by pulling the current <$link to value into a variable, and using it to generate a wikified result, which you could then paste as the <$link to value.

Best of luck!

1 Like

Hello @Scott_Sauyet,

I was able to make a step forward by myself :smiley:

title: $:/core/ui/ViewTemplate/title/default

\whitespace trim
<h2 class="tc-title">
<$list filter="[{$:/language}] +[removeprefix[$:/languages/]]" variable="selected-language">
<$link to={{{[<currentTiddler>has<selected-language>get<selected-language>has[caption]get[caption]] 
:else[<currentTiddler>has<selected-language>get<selected-language>has[title]get[title]]
:else[<currentTiddler>has[caption]get[caption]]
:else[<currentTiddler>has[title]get[title]] }}}/>
</$list>
</h2>

What I do not understand is why it is only working togehter with your solution posted here: Display the caption field instead of the tiddler title in story line

Ok it works, fine :+1:

Stefan

1 Like