[TW5] Any way to stop transcluded tiddlers {{!!title}} from matching the parent title?

70 views
Skip to first unread message

Jeff Vance

unread,
Feb 16, 2017, 12:25:53 AM2/16/17
to TiddlyWiki
I'm very confused on how to manage the currentTiddler and {{!!title}} entries in a tiddler when it becomes transcluded.  I get that this is a powerful feature that allows a template tiddler to take on the title of whatever tiddler it is transcluded into.  But what about situations when I specifically don't want this?  Is there a way to force it to use the original title?

For example: In my current case, I have many weekly tiddlers that use macro to generate a table of journal entries for a week. It uses the title of that tiddler to get the week number, then it finds all the journal entries for that week. Now, I suddenly had this idea that I can collect all the weeks into a Yearly tiddler, using Tabs for each week. However, transcluding all the "week" tiddlers into the new tiddler containing the tabs prevents the macro from working since it tries to use the new title for the "week" parameter.  The only thing I can think of at the moment is to rewrite the macro to not use the title field and instead use another field that can contain the week number.  But that seems like a pain since I would have to update all the current weeks to contain the new field.

Eric Shulman

unread,
Feb 16, 2017, 12:48:33 AM2/16/17
to TiddlyWiki
On Wednesday, February 15, 2017 at 9:25:53 PM UTC-8, Jeff Vance wrote:
I'm very confused on how to manage the currentTiddler and {{!!title}} entries in a tiddler when it becomes transcluded.  I get that this is a powerful feature that allows a template tiddler to take on the title of whatever tiddler it is transcluded into.  But what about situations when I specifically don't want this?  Is there a way to force it to use the original title?

Try this little trick:

At the beginning of each weekly tiddler, put
<$tiddler tiddler=<<currentTab>>
and at the end, put
</$tiddler>

When the weekly tiddler is viewed directly, <<currentTab>> will NOT have a value, so the <$tiddler> widget will have no effect, and the weekly tiddler will display as usual.  However, when viewed in a tabset (i.e., as part of the Yearly "roundup" of tiddlers), the <<currentTab>> value WILL be defined and the <$tiddler> widget will set the <<currentTiddler> value to match the <<currentTab>> value, instead of having <<currentTiddler>> unchanged (i.e., referencing the tiddler in which the tab set is contained).

Note, instead of modifying each and every weekly tiddler to put in this "wrapper", you could use a template tiddler to automatically add the <$tiddler>...</$tiddler> widget to each weekly tiddler shown in the tabset, without editing any of those tiddlers directly.

Start by creating a tiddler (e.g., "YearlyTabsTemplate"), containing:
<$tiddler tiddler=<<currentTab>><$transclude mode="block"/></$tiddler>

Then, in your <<tabs>> macro, specify the "template:" parameter to be used to render the tabs, like this:
<<tabs .... template:"YearlyTabsTemplate">>

That should do it.  Let me know how it goes.

enjoy,
-e
Eric Shulman
TiddlyTools: Small Tools for Big Ideas(tm)
InsideTiddlyWiki: The Missing Manuals

Jeff Vance

unread,
Feb 16, 2017, 10:10:02 AM2/16/17
to TiddlyWiki
This is an interesting trick.  I gave it a try and it worked.  And thanks for the template idea, although I didn't need to do that in this case.  I'm already using a macro that then calls the tabs macro, getting the current tiddler title.  So I just put the <$tiddler> entry inside that outer macro, before calling <<tabs>> and it is working in all the instances.
Reply all
Reply to author
Forward
0 new messages