Caption change by field of different tiddler

Hello TiddlyWiki.Experts,

I want to change the caption of the tiddler by importing the content of a field in a different tiddler.

But I failed by using the $action-setfield operator

Example:

caption: I am A
created: 20241211102606622
creator: Team
modified: 20241211102648430
modifier: cISMS Team
tags: 
title: Tiddler_A

{{Tiddler_B}}

{{Tiddler_C}}
caption: I am B
created: 20241211102521226
creator: Team
modified: 20241211102555781
modifier: cISMS Team
tags: 
title: Tiddler_B

''"B"''

Will result in:
image

In some cases, not always, of my usecase I want to import into Tiddler A

  1. the caption of Tiddler_B
    and
  2. the author information of Tiddler_C.

I hope you understand what I want to achieve. If not let me know.

Thx in advance for any support

Stefan

Hi

You could use

{{Tiddler_A!!caption}}

{{Tiddler_C!!creator}}

in tiddler Tiddler_A

Hope this helps,

Fred

Hi @tw-FRed,

Thank you for your quick answer.
This will display the field at the position of {{…}}.
But I want to change the content of the field in Tiddler_A

<$action-setfield $tiddler="<<currentTiddler>>" caption="{{Tiddler_B!!caption}}"/>

Is the caption still “I am A” instead of “I am B” what I am looking for.

Maybe I misunderstood how to use your solution?

Stefan

You are mis-using the double quotes. They indicate that the parameter values are literal text, and therefore the references are not interpreted. Do this instead:

<$action-setfield $tiddler=<<currentTiddler>> caption={{Tiddler_B!!caption}}/>

Also, note that the default if the $tiddler parameter is omitted to use the current tiddler so you can further simplify:

<$action-setfield caption={{Tiddler_B!!caption}}/>

enjoy,
-e

Hi @EricShulman

this is not working as expected :’(

Here are the 3 example Tiddlers I use:

author: Autor of C
caption: I am C's caption
created: 20241211135141523
creator: Team
modified: 20241212092431545
modifier: Team
tags: 
title: Tiddler_C

''"C"''
caption: I am B's caption
created: 20241211102521226
creator: Team
modified: 20241212092241391
modifier: Team
tags: 
title: Tiddler_B

''"B"''
author: The author of A
caption: The caption of A
created: 20241211102606622
creator: Team
modified: 20241212093616353
modifier: Team
tags: 
title: Tiddler_A

{{Tiddler_B!!caption}}
<$action-setfield caption={{Tiddler_B!!caption}}/>

{{Tiddler_C!!author}}
<$action-setfield author={{Tiddler_C!!author}}/>

Addtionaly this tiddler to display the caption instead of the title:

author: Team
code-body: yes
created: 20230830142553245
creator: Team
list-before: $:/config/ViewTemplateTitleFilters/default
modified: 20240729073543724
modifier: cISMS Team
revision: 0
tags: $:/tags/ViewTemplateTitleFilter
title: $:/_/my/config/ViewTemplateTitleFilters/caption
type: text/vnd.tiddlywiki

[<currentTiddler>has[caption]then[$:/_/my/core/ui/ViewTemplate/title/caption]]

But the result is still this.
The caption will not be used.
image

Any Idea? I am confused …

Stefan

Using an $action-setfield widget by itself within tiddler content does nothing. All $action widgets, including $action-setfield need to have some kind of user interaction to trigger them. This is most often a $button widget, like this:

<$button actions="<$action-setfield caption={{Tiddler_B!!caption}}/>">set caption</$button>

and

<$button actions="<$action-setfield author={{Tiddler_C!!author}}/>">set author</$button>

However, I don’t think this is what you really want. Instead, I think you want the caption of TiddlerA to automatically show the caption value from TiddlerB, and the author of TiddlerA to automatically show the author value from TiddlerC.

To do this, you can just transclude those values directly into the fields of TiddlerA by editing TiddlerA and entering {{TiddlerB!!caption}} into TiddlerA’s caption field, and entering {{TiddlerC!!author}} into TiddlersA’s author field. Then, when those fields are displayed in TiddlerA, the transclusion is processed to render the values from the other two tiddlers.

-e

Hi @EricShulman,

thank you for your support.
So far understood.
Is is it possible to trigger the action wihin a list?
I am using a multilingual solution here.
The Tiddler will be displayed by the selection of the language and the target tiddler provided in the field same named as the language eg en-GB, de-DE, etc

Idea!

Use it here also but I think I misunderstood the trigger and transculsion function.

<$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>> />

<$action-setfield $tiddler="<<currentTiddler>>" caption="{{<<thislanguage>>!!caption}}"/>

</$list>
</$list>

Thx in advance
Stefan