On Monday, February 3, 2020 at 4:03:51 PM UTC-8, Michael McDermott wrote:
>
> Is there a way to semantically model some relationship between two
> tiddlers?
> For example, in a graph database, you might create a relationship like
> this:
> [Leonardo da Vinci] ----Painted---> [The Mona Lisa]
> Is there a good option in TiddlyWiki I've missed?
>
You can create any "custom" fields you like on a tiddler.
To represent a one-to-one relationship between painting and painter, you
could define
a "paintedby" field for a painting, the value of which would be the title
of a "painter" tiddler.
e.g., [[The Mona Lisa]] tiddler would have a "paintedby" field containing:
"Leonardo Da Vinci".
Conversely, to represent one-to-many relationships, you could define a
"painted" tiddler for
an artist, the value of which would be a space-separated list of titles of
paintings.
e.g., [[Leonardo Da Vinci]] tiddler would have a "painted" field
containing: [[The Mona Lisa]] [[The Last Supper]] [[Salvator Mundi]]
Then, to display a list of all his works, you can write in the [[Leonardo
Da Vinci]] tiddler:
<$list filter="[list[!!painted]]"><$link /><br></$list>
Alternatively, if not all paintings by Da Vinci are entered into the
"painted' field, you can still list all his paintings using a filter that
looks for his name in the "paintedby" field of other tiddlers, like this:
<$list filter="[all[tiddlers]paintedby<currentTiddler>]">...</$list>
For a more complex example, let's suppose that each artist tiddler is
tagged with "artist". Then, you could create a list of all paintings in
the document, grouped by artists, using something like:
<$list filter="[tag[artist]]">
<$link />
<blockquote>
<$list filter="[all[tiddlers]paintedby<currentTiddler>]"><$link /><br>
</$list>
</blockquote>
</$list>
The outer $list finds all artist tiddlers and displays their titles, while
the inner $list shows all the tiddlers for the current artist (inside a
blockquote for nicer formatting
enjoy,
-e
--
You received this message because you are subscribed to the Google Groups
"TiddlyWiki" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/tiddlywiki/5f0c2fd3-3819-42bd-bb85-36dd69be7693%40googlegroups.com.