3

I'm trying to use tiddlywiki to build a store of parts I ordered online. Each tiddly represents one part and has several fields, such as price or order-number... How can I use Tiddlywiki fields within the Tiddlywiki markup or HTML, eg. how can I make this to work:

<a href="distributor.org/search?q={{!!order-number}}">View Online</a>

I would like that Tiddlywiki replaces {{!!order-number}} by the value of the field order-number. But unfortunatly, {{!!order-number}} is not rendered.

Note that in the following snippet, it works partially:

<a href="distributor.org/search?q={{!!order-number}}">View Online {{!!order-number}}</a>

Specifiyng the field between the a-tag (not in href) is render correctly, showing the value of the field {{!!order-number}}.

YakovL
  • 7,557
  • 12
  • 62
  • 102
RangerJo
  • 391
  • 2
  • 7

1 Answers1

3

I finally found a working solution myself, which works for TW 5.1.13:

\define build-link()
<a href="distributor.org/search?q=$(orderNumber)$">distributor</a>
\end

<$set name=orderNumber value={{!!order-number}}>
<<build-link>>
</$set>
  1. Define the desired field, in this example order-number
  2. Define a macro that includes a variable, eg. the macro build-link which uses the variable orderNumber. Note that the macro must be at the beginning of the tiddle.
  3. Set a variable with the name as defined above.
  4. Call the macro within the varible set environment.

This also works with Wikitext markup:

\define build-link-mu()
[ext[distributor|distributor.org/search?q=$(orderNumber)$"]]
\end

<$set name=orderNumber value={{!!order-number}}>
<<build-link-mu>>
</$set>
RangerJo
  • 391
  • 2
  • 7