How to build a transclusion from fields in other tiddlers?

134 views
Skip to first unread message

Mark Hylton

unread,
May 12, 2021, 10:49:48 AM5/12/21
to TiddlyWiki

I want to build a transclusion from the text of one tiddler and the returned lookup value from a data tiddler. For example. I want to build and evaluate ``{{drill##101}}`` and get ``P01.02.03`` from the following pieces:

* ``{{AplicationChoice}}`` evaluates to or contains ``drill``, and
* Data tiddler ``drill`` has an entry ``101:P01.02.03``, and
* ``{{ID101!!idnumber}}`` is ``101``, and
* I want to do this transclusion from the ``ID101`` tiddler (or from other ID tiddlers with different ID numbers).

Conceptually, from tiddler ID101 I'd like to evaluate ``{{ApplicationChoice##{{!!idnumber}}}}`` and get ``P01.02.03`` ... but that isn't working. I'll admit to not well understanding use of braces, square brackets, angle brackets and spacing to control evaluation of text.

***Background

There are tiddlers for each of the multiple IDs (e.g., ID101, ID102, ID103, ...), and data tiddlers for each of the multiple applications (e.g., drill, saw, hammer, ...). There are multiple Ps (e.g., P01.01.01, P03.01, P03.01.04, ...) but no tiddlers are defined for each P number. I select the current application by using a selection list to put the selected application into tiddler ``ApplicationChoice``. I want the ID number tiddlers to display their associated P number based on the selected application.

Note that the ID number and the P number are different, separate from each other, and have a many-to-many relationship. The particular relationship to use is based on the application chosen (e.g., drill, or saw, or hammer), so I can't put a constant ID number field in P tiddlers, and I can't put a constant P number field in the ID number tiddlers. This relationship has been provided to me and I can't change it. P numbers are used to navigate an interface (they are the screen name), and ID numbers contain the actual nuggets of information.

Thanks ahead of time for any suggestions!

~Mark Hylton

Soren Bjornstad

unread,
May 12, 2021, 6:38:56 PM5/12/21
to TiddlyWiki
If I'm understanding what you want correctly, the easiest way is a filtered transclusion with the getindex operator:

{{{ [{ApplicationChoice}getindex{!!idnumber}] }}}

If you don't want the result to show up as a link, you can use the $text widget:

<$text text={{{ [{ApplicationChoice}getindex{!!idnumber}] }}}/>

As you noted, {{ApplicationChoice##{{!!idnumber}}}} doesn't work. TiddlyWiki doesn't parse wikitext inside double braces, so once you get into the first {{, it's not going to know what to do with {{!!idnumber}}.

Mark Hylton

unread,
May 13, 2021, 8:54:31 AM5/13/21
to TiddlyWiki
Thank you much, Soren, both examples work perfectly! Hopefully I'll get to the point, some day, where I actually understand this syntax and can graduate from being a script kiddie. But in the meantime, I can use this.

Thanks again!

scot

unread,
May 13, 2021, 9:57:30 AM5/13/21
to TiddlyWiki
Hello Markh and Soren
I would like to see a working example of your solution.

Is there any way you could provide an example in tiddlyhost.com or attach .tid files as  do not have existing Tiddlers required.
Thanks Scot

Mark Hylton

unread,
May 14, 2021, 1:13:09 PM5/14/21
to TiddlyWiki
Attached are a set of TID files that are close to the minimum needed to see how this is working. Please understand that this is a work-in-progress and is missing some functionality and polish ... but it does illustrate Soren's solution.

After bringing these tiddlers into your TW, start with the "Listings" tiddler. In that tiddler, select "Multi-Step Speed Control" in the selection box at the top, then click on one of the ID tiddlers (say, "ID 101"). Edit "ID 101" and look at the "idindex" field where you will find one of Soren's solutions. The effect is that "ID 101" will get the currently selected application (the content of tiddler "ApplicationChoice") which is "multistepspeed", look in data tiddler "multistepspeed" for the "101" entry (the number of the current tiddler's ID as stored in "{{ID 101!!idnumber}}"), get the P index number associated with "101", and provide that P index number to be displayed.

This complexity is imposed because any particular ID may reference different P indexes, and any particular P index may reference different IDs; there is always a one-to-one relationship after an application is chosen, but that relationship changes depending on the which application is chosen.

Note that the ID table in "Listings" doesn't alphabetize correctly on the P index column, probably because the sort[idindex] can't see the actual value being stored in the ID tiddler field "idindex". Don't know this for sure, though. This may not be evident with the small set of ID tiddlers that I've provided.

*****Additional background

I had used drill, saw, and hammer as application names because they would be more familiar. But, what I'm actually doing is TWifying a manual for a variable frequency drive (VFD) because the existing manual has poor linking and doesn't have a complete set of information for an ID in a single place. Plus, I wanted to add notes and practice my TW-foo; I don't expect to copy the complete manual into my TW, only those parts that are most needed for my use of the VFD. The "applications" are different ways to use the VFD for motor control, the IDs are the various parameters that can be set to control the motor operation, and the P index is the name of the menu displayed on the 4 (ish?) line operator interface of the VFD.

Hope this helps you, Scot. Have a good weekend!
8 TID files.zip

scot

unread,
May 14, 2021, 3:35:53 PM5/14/21
to TiddlyWiki
Hello markh
thank you so much for taking the time to reply to my request for examples of your data and the structure of the files.
Have a nice weekend.
Scot
Reply all
Reply to author
Forward
0 new messages