I am having trouble with the <$link> widget to output the value of a field

I am using the filter below but the <$link> widget keeps outputting the name of the field.

<$list filter="[<currentTiddler>fields[]prefix[field-name]]" variable="thisfield">
  <$link to=<<thisfield>>>❮❮</$link>
</$list>

I realize normally it would work if I could just use:

<$link to={{!!field-name}}>❮❮</$link>

What is that I am missing?

You are getting what you are asking for;

[<currentTiddler>fields[]prefix[field-name]]

  • For the current tiddler
  • Get all field names on the on the current tiddler
  • But only “fieldnames” with the prefix “field-name”

So I am guessing what you really want is the value in each fieldname. To do this we first need the list of fieldnames and then we need to retrieve the value for each fieldname;

<$list filter="[<currentTiddler>fields[]prefix[field-name]]" variable="thisfield">
  <$link to={{{ [all[current]get<thisfield>] }}}>❮❮</$link>
</$list>

However I am suspicious that you do not have multiple fields with the prefix “field-name”.

This example shows that, as a rule, a filter usually returns one item or a list of items and not two lists of different items.

  • For example the list widget above returns a list of fieldnames,
  • it can’t return a list of fieldnames AND a list of fieldvalues.

Although people often avoid nested lists they can be very helpful;

<$list filter="[<currentTiddler>fields[]suffix[-link]]" variable=fieldname>
   <$list filter="[all[current]get<fieldname>]" variable=fieldvalue>
        <<fieldname>>=<<fieldvalue>><br>
        <$link to=<<fieldvalue>> > <<fieldname>> </$link>
   </$list> 
</$list>

So inside the inner list we have access to all values that each of the filters determined for us.

  • Notice how the lists set their own variable name so the <<currentTiddler>> stays unchanged.
  • Notice how in the inner list
    • we need to both state again we are referring to the “all[current]” tiddler
    • The inner filter also references the value found in the outer filter

Thanks, this was very helpful.

After work, I finally had some time to look at your second code. I think it works better than the first one. I spent hours trying to get that image to work properly. Your example made it that much easier. This is how I used the code:

<$list filter="[<currentTiddler>fields[]suffix[-link]]" variable=fieldname counter=num>
  <$list filter="[all[current]get<fieldname>]" variable=fieldvalue>
    <span class={{{ [[link link-class-]addsuffix<num>] }}}>
      <$link to=<<fieldvalue>> > ❮❮ <!-- or --> ❯❯ </$link>      
        <span class="tooltip">
          <span class="icon">
            <$image source={{{ [<fieldvalue>get[icon]addprefix[/image-path/]addsuffix[.png]] }}}/>
          </span>
          <$text text=<<fieldvalue>>/>
        </span>
      </span>
    <br>
  </$list> 
</$list>
<style>
span.link {
  position: relative;
}
span.tooltip {
  position: absolute;
  visibility: hidden;
}
span.link:hover span.tooltip {
  visibility: visible;
}
</style>