Scope of {{!!field}}

134 views
Skip to first unread message

Brian Diamante

unread,
Jun 6, 2019, 1:12:29 AM6/6/19
to tiddl...@googlegroups.com
I have a tiddler that contains a field called month. The tiddler text refers to {{!!month}} to grab the field value and pass it as a parameter into a macrocall macro. It correctly pulls the month field value and everything works as it should. However, when I call the tabs macro in a new tiddler and have it display the original tiddler as a tab, the {{!!month}} reference breaks and appears to now reference the tiddler calling the tabs macro.

Is there a way to lock the scope of the {{!!month}} variable to the original tiddler? Perhaps I'm overlooking a simple way of doing this?

Thanks!

PMario

unread,
Jun 6, 2019, 3:06:28 AM6/6/19
to TiddlyWiki
Hi,
Have a closer look at: https://tiddlywiki.com/#tabs%20Macro ... Near the end, where it talks about the template
-m

TonyM

unread,
Jun 6, 2019, 4:57:07 AM6/6/19
to TiddlyWiki
Brian

In the text reference !!fieldname you are not specifying the tiddler name as in tiddlername!!fieldname. Thus it applies to current tiddler not the tiddler it is coded in.

You can change the way you reference the fieldname in another tiddler by including the tiddler name or set the current tiddler. The current tiddler is set by default inside lists or you can use the tiddler widget

<$tiddler tiddler=tiddlername>
in here current tiddler is tiddler name
So {{!!title}} is the same as
{{tiddlername!!title}} and <<current Tiddler>>
</$tiddler>

I hope this helps because I can see you need to make this conceptual leap.

Regards
Tony

Brian Diamante

unread,
Jun 6, 2019, 11:36:32 AM6/6/19
to tiddl...@googlegroups.com
Hi Tony,

As usual, I left out a couple of important details. I'm using the tiddler referencing {{!!month}} as a template so pulling the field from the current tiddler is my intention. I'm trying to get around having to explicitly include the tiddler title in the fieldname reference (don't want to use {{October!!month}}).

Adding a little more detail, my tiddler looks like this:
<$macrocall $name="my-calendar" year={{$:/tdg/vars/calendar-schoolyear-startyear!!year}} month=10/>

!! Reports Due This Month
<div class="twocolumns">
<div class="twocolumns-col">
<$macrocall $name="custom-links"
monthtag=October sorttype=<<cal-sort-type>> sortby=day/>
</div>
</div>


I want to use this template in 12 tiddlers, one for each month, which will then be viewed in a separate tiddler via the tabs macro. I'm trying to get around having to manually change the month number (10 in the example above) and month tag (October in the example above) in each of the 12 month tiddlers. Generally speaking, I would have other uses for this type of abstraction as well, but can't get it to work.

If I use a field reference ({{!!month}}, for example) insead of the explicit month number/tag, it works fine in the tiddler, but breaks in the tabs tiddler.

I've tried various set widget combos and macros but can't get it to work.

Thanks,
Brian

BJ

unread,
Jun 6, 2019, 1:38:47 PM6/6/19
to tiddl...@googlegroups.com
the tabs macro uses the variable 'currentTab' so you could test for currentTiddler being empty and if so use the currentTab:


<$set name="currentTiddler" filter="[all[current]]" value=<<currentTiddler>> emptyValue=<<currentTab>>>
<$text text={{!!month}}/>
</$set>


This works only in the sidebar

possible this:


<$set name="currentTiddler" filter="[all[current]field:title<currentTab>]" emptyValue=<<currentTab>> value=<<currentTiddler>> >
<$text text={{!!month}}/>
</$set>


Eric Shulman

unread,
Jun 6, 2019, 2:19:21 PM6/6/19
to TiddlyWiki
On Thursday, June 6, 2019 at 10:38:47 AM UTC-7, BJ wrote:
the tabs macro uses the variable 'currentTab' so you could test for currentTiddler being empty and if so use the currentTab:
<$set name="currentTiddler" filter="[all[current]]" value=<<currentTiddler>> emptyValue=<<currentTab>>>
<$text text={{!!month}}/>
</$set>


There's another, much simpler way to do this, using the <$tiddler> widget.  Just add the following in any tiddler that you want to show in a tabset:

<$tiddler tiddler=<<currentTab>>>
...
tiddler content goes here, e.g.,
<$text text={{!!month}}/>
...
</$tiddler>

When the tiddler is displayed directly, the <<currentTab>> variable is undefined, and the <<currentTiddler>> is unchanged (i.e., the $tiddler widget has no effect).  However, when the tiddler is displayed **within a tabset**, the <<currentTab>> variable *is* defined, and the <$tiddler> widget changes the <<currentTiddler>> value to match the title of the tiddler being displayed in the tab, allowing 'local' field references (i.e., {{!!!month}}) to work as desired.

enjoy,
-e




Brian Diamante

unread,
Jun 7, 2019, 6:49:15 PM6/7/19
to TiddlyWiki
This is great. Didn't know about <<currentTab>>... so many possibilities!

I appreciate the help!

Brian
Reply all
Reply to author
Forward
0 new messages