Referencing a Field in another Tiddler during Transclusion

122 views
Skip to first unread message

Scott Masterson

unread,
Jun 21, 2020, 11:16:34 PM6/21/20
to TiddlyWiki
Hello All,

This is my first post here, so please forgive my naiveite and beginner status.  BLUF: I'm trying to create a prototype for a notification system for a relatively complex military organization, and I'm trying to figure out how to reference the fields of one Tiddler, while transcluding another Tiddler field into a list in that Tiddler?

Now here's the long-winded version.  Each Unit Tiddler in the organization has a field with that unit's ID, called the unit-opfac, as well as a field for its parent unit, called the parent-opfac.  A Brief Tiddler can be created (from a button generating a Tiddler based on the Brief Template) at any unit level and will be tagged with [Brief] as well as its unit-opfac and its parent-opfac.  I want to use the checkbox widget to allow each brief to be promoted up the organizational chain by being tagged with the unit's parent-opfac. This will allow someone at each unit level to promote a brief up the chain at will.  I wrote the below code and thought I was doing great - until I realized that the parent-opfac and unit-opfac fields that I was transcluding were from the Brief Tiddler, and not the Unit Tiddler.  So, how can I filter/modify tags that are based on fields in the Unit Tiddler, rather than those in the Brief Tiddler?  I think the logic I've written will do what I want (see below), IF I can figure out how to reference the correct fields.  Thanks in advance!

Scott
  

Unit Tiddler

Tags: Title of Parent Unit

Tiddler Text:

! Promoted Briefs
<$list filter="[!has[draft.of]tag[Brief]tag[{!!parent-opfac}]tag[{unit-opfac}]sort[created]]">
   
<div>
       
<$checkbox tag={{!!parent-opfac}}> __<$link to={{!!title}}><$view field="title"/></$link>__</$checkbox>
    </
div>
</$list>

! Incoming Briefs
<$list filter="[tag:[Brief]tag:{!!unit-opfac}!tag[{!!parent-opfac}]sort[created]]">
    <div>
        <$checkbox tag={{!!parent-opfac}}> <$link to={{!!title}}><$view field="title"/
></$link></$checkbox>
   
</div>
</
$list>

Fields:
parent
-opfac: 14-00000
unit
-opfac: 14-33296


Brief Tiddler

Tags: Every unit-opfac the Brief Tiddler is promoted to.

Tiddler Text: Some briefing text...

Fields:
parent
-opfac: 14-33296
unit
-opfac: 14-33296-P

TW Tones

unread,
Jun 22, 2020, 12:09:16 AM6/22/20
to TiddlyWiki
Scott,

Quick tip, in your lists above the `<<currentTiddler>>` changes according to the list filter, that is why {{!!title}} refers to the tiddler in the list (result of the filter). However you could always use another variable=other-tiddler in the list statement to keep referring to the original tiddler, but then you will have to use the <<other-tiddler>> variable say in the viewWidget to access the other fields in <<other-tiddler>>.

At anyplace in your wikitext you can set the current tiddler to another, using the tiddler widget, and this can be driven by a variable 
<$tiddler tiddler=<<other-title>> >

In here <
<currentTiddler>> = <<other-title>> and {{!!title}} refers to the title in <<other-title>>

</$list>

Also if you know how to access a tiddler and its field with a filter you can wrap that filter in triple Curly Braces
eg
{{{[<other-tiddler>get<fieldname>]}}}

Ask more questions once you explore these tips.

Tony

Scott Masterson

unread,
Jul 2, 2020, 3:36:29 AM7/2/20
to tiddl...@googlegroups.com
Hey Tony,

Thanks for the tips, they're really appreciated.  I found an easier way to do what I wanted, without having to change the currentTiddler.  Unfortunately, I'm having a problem with the syntax in the list filter that's driving me a bit crazy.   In the list filter, if I put the actual field values into the tag filter, it works perfectly.  But if I use text references for the fields, nothing is returned.  I've tried every syntax combination I can think of, and nothing seems to work.  I'm using a $button for the list items now and the list is always empty.  But when I was using a $checkbox for the list items, then the filter seemed to work fine.  

Here's the list filter with the direct field value substitutions, and it works fine:

<$list filter="[!has[draft.of]tag[Brief]tag[14-33296]!tag[14-00000]sort[title]]">
    <div>
        <$button><$action-listops $tags="[{!!super-opfac}] -[{!!parent-opfac}]"/>Promote</$button>
        <$link to={{!!title}}><$view field="title"/></$link>
    </div>
</$list>

But when I try to use text references for the field values, it doesn't work:

<$list filter="[!has[draft.of]tag[Brief]tag{!!parent-opfac}!tag{!!super-opfac}sort[title]]">
    <div>
        <$button><$action-listops $tags="[{!!super-opfac}] -[{!!parent-opfac}]"/>Promote</$button>
        <$link to={{!!title}}><$view field="title"/></$link>
    </div>
</$list>

Forgive my inexperience with Tiddlywiki, but can you help me understand what I'm doing wrong?

Thanks in advance,
Scott

TW Tones

unread,
Jul 2, 2020, 4:18:02 AM7/2/20
to TiddlyWiki
Scott

Try adding variable=nul as a parameter in your list widget so the currentTiddler variable does not change and field reference refer to the original tiddler remain valid.

I will look closer later

Regards
Tony

Scott Masterson

unread,
Jul 5, 2020, 8:39:48 PM7/5/20
to TiddlyWiki
Tony,

Never mind, it was my bone-headed mistake.  I had the closing tag for the $set widget before the $list widget, so the variable I was using was going out of scope before the list filtered on it.  Thanks for your help.

Scott
Reply all
Reply to author
Forward
0 new messages