Create a link if field content match to existing tiddler name

Hi TW-Experts,

I have this nice generator what lists all fields of a Tiddler.

<table class="pretty">
	<$list filter="[enlist<fields>]" variable="field">
	<tr>
		<td><<field>></td>
	</tr>
	</$list>
</table>

What I am looking for is that if the content of the field is an existing tiddler to get it as link, and if not only the content of the field:

Eg:

  • Tidller_A has fields Name and City.
  • Hamburg is an existing Tiddler.

If Tiddler_A field Name is Stefan and City is Berlin the out put should be “Stefan” and “Berlin”.
But if the Tiddler_A field City is “Hamburg” I want to have the link to the Tiddler “Hamburg”.

The question is more or less, how to check for an existing Tiddler and to select the right output procedure.

Thx in advance for help
Stefan

Using the conditional syntax <% if %>, <% elseif %>, <% else %> and <% endif%>, would let you do this, using is[tiddler]:

<% if [<currentTiddler>get<field>is[tiddler]] %>
  <$link to = {{{ [<currentTiddler>get<field>] }}} />
<% else %>
  <$text text = {{{ [<currentTiddler>get<field>] }}} />
<% endif %>

FieldLinks.json (1.2 KB)

Update:

<$link to = {{{ [<currentTiddler>get<field>] }}} />

is probably better written as

{{{ [<currentTiddler>get<field>] }}}

Thank you so much @Scott_Sauyet