I have a tiddler that has an associated template. This tiddler shows properly in the story. When I show this tiddler in a tab on another tiddler the template is not utilized. I think I know why–the current tiddler is different. How can I get the template to function with tiddlers shown on tabs?
Please see https://tiddlywiki.com/prerelease/#tabs%20Macro
and read the last paragraph
Within the template, the title of the selected tab is available in the
currentTab
variable.The
currentTiddler
variable is not affected by thetabs
macro. This can put you in trouble if the list of tabs includes tiddlers that depend on the value of thecurrentTiddler
, for example tiddlers listing children based on its own name. To overcome this problem you can use a TemplateTiddler like the following:<$tiddler tiddler=<<currentTab>>> <$transclude mode="block" /> </$tiddler>
@Mohammad Thank you. I was reading this last night. I was not fully understanding it. However, I think I get it now. Having said that my situation is a nested tab. The parent Tiddler displays a set of tabs horizontally. On one these tabs it shows a set of vertical tabs. When I use currentTab it recognizes the parent tab, not the selected sub tab.
Correction. I’m being fooled. I don’t think that is occurring—ie. it is not just working on parent tab. It’s just not working at all. Still debugging.
Are you sure your reference to currentTab is within the 2nd level tab or in its parent?
- I have done this in the past and it does work within sub tabs
- Also, You may see the value outside the current tab if you refer to
$(currentTab)$
rather than<<currentTab>>
but I need to double check this. - The core tabs are fairly well documented tabs Macro
- Take particular note of the example template at the bottom, which if you introduce a template on the parent and child tabs macro call you can gain a lot of control over this.
- It takes a little cognitive gymnastics to wrap you head around this but it is very powerful.
- Keep also in mind when the same variable is used within a parent and its child macro, it can in fact be the same variable name in both, but with different values depending on where it is used, each level in effect redefines the same variable.
You can learn from an example
- Open Kara Tutorial
- See how template is used whenever tabs macro is called (edit Kara Tutorial tiddler and look at the tabs macro and template attribute)
- Open the template $:/tabs/tabTemplate
@TW_Tones @Mohammad Thank you. Sorry for the delay. Beautiful weather here and I needed to do some repairs to my shed. I was breaking a rule of mine—don’t give power or hand tools to software developers. So my repairs took longer than expected.
I knew this template issue was going to be a user error. I was misunderstanding how to implement it. All I needed to do was read the documentation properly. However, once I saw the example I was able to immediately fix my usage.
I know you’re going ask—what was I doing wrong. I was trying to get the template to work without using the template parameter of the tab widget.