Using tab macro in viewTemplate

99 views
Skip to first unread message

Damon Pritchett

unread,
Apr 29, 2020, 5:59:36 PM4/29/20
to TiddlyWiki
Hello all,

I've been playing around for the last couple of days experimenting with adding a viewTemplate with a tabbed interface as a footer to tiddlers tagged with a certain tag. I've been able to make this sort of work with the tab macro and I've also used the tabber macro of Mat's, but both solutions have a couple of things that I'm not quite satisfied with. Using the tabber macro, the tab last visited on a given tiddler is the one that is selected by default when I open the next tidder. Also with tabber, if I have two tiddlers open at the same time I can't have two different tabs in each tiddler since each tab has a single state tiddler associated with. I solved those problems by using the built-in tab macro, but because I have nearly two thousand of the tiddlers in question, I'm going to get nearly two thousand state tiddlers eventually. I've also noticed that the first time I open any given tiddler, there is no tab selected. I'm assuming that's because no state tiddler has been created yet. I've also tried using CSS only tabs, which works fine when only one tiddler's open, but, if two or more are open, only the most recently opened one has working tabs.

I'm looking for any other suggestions on how to make this work. So far, I like using the built-in tab macro best, but I worry about performance after a few hundred (or whatever the number might be) state tiddlers are created. Is this even a concern?

Many thanks,

Damon

Saq Imtiaz

unread,
Apr 29, 2020, 6:38:20 PM4/29/20
to TiddlyWiki
TW on node doesn't save state tiddlers and you can set the single file version to do the same. Search this group for "publishFilter"

The tabs macro lets you set a default tab that should be active if no state tiddler exists.

TonyM

unread,
Apr 29, 2020, 7:33:38 PM4/29/20
to TiddlyWiki
As Saq said,

In fact a default tab is irrelevant if the state tiddler exists with a value.  

Daemon do you want a detailed example or is this info enough for you to proceed?

Regards
Tony

Mat

unread,
Apr 30, 2020, 8:51:02 AM4/30/20
to TiddlyWiki
Damon, you solve this by making the state tiddlers title based on the current tiddler title.
Here's the general idea:

\define state() state/footer/$(currentTiddler)$

<$button>
<$action-setfield $tiddler=<<state>> text="xxx"/>
x
</$button>

You might also want to check out the qualify macro but I don't think you need this here.

<:-)



On Wednesday, April 29, 2020 at 11:59:36 PM UTC+2, Damon Pritchett wrote:

Damon Pritchett

unread,
Apr 30, 2020, 5:15:04 PM4/30/20
to TiddlyWiki
All,

Thanks for the suggestions. I did find that using the publishFilter idea works great for not having to worry about a couple of thousand state tiddlers being saved with the TW. However, I'm finding that the default tab from the macro call is being ignored when there is no state tiddler. This is similar to another default tab issue that I've had a few weeks ago that is still not solved.

Mat, your idea would solve the default tab problem, but that still leaves a couple of thousand state tiddlers eventually being around. Is that a performance concern for my TW which is already nearly 9MB? I started to play with your suggestion, but I got confused as to why the button was there. What would be the workflow on this? Would I click that button to save the state tiddler when I first visit each tiddler that this is being used in? 

Another question I just thought of is can I use a field in the tiddler to set the default state of the tabs? That way, each tiddler could have its own default defined like Mat's idea, but there would be so many state tiddlers.

Thanks,

Damon

Saq Imtiaz

unread,
Apr 30, 2020, 5:23:21 PM4/30/20
to TiddlyWiki
I have a TiddlyWiki that generates one state tiddler per content tiddler, so every time the wiki is open I have a few hundred state tiddlers open. No peformance impact. And if you configure so they don't get saved there is no problem with size either.

For the default tab, please post the code in which the default value is not being respected. There may be a syntax error that you are not catching.

Damon Pritchett

unread,
Apr 30, 2020, 5:26:09 PM4/30/20
to TiddlyWiki
Here's the code for my footer:

<$list filter="[all[current]tag[Railroads]]" variable="dummy">

<div style="font-size: 0.9em;">

<hr class="double">
  <<tabs "[[Railroad Footnotes]] [[Railroad Predecessors]] [[Railroad Successors]] [[Railroad Cross-references]] [[Railroad Status Checkboxes]]" "[[Railroad Footnotes]]" "$:/state/rrfootertab" "footertabs">>
</div>

</$list>

Saq Imtiaz

unread,
Apr 30, 2020, 5:51:29 PM4/30/20
to TiddlyWiki
  <<tabs "[[Railroad Footnotes]] [[Railroad Predecessors]] [[Railroad Successors]] [[Railroad Cross-references]] [[Railroad Status Checkboxes]]" "Railroad Footnotes" "$:/state/rrfootertab" "footertabs">>

The default does not need double brackets around it, as it is just one tiddler title and has quotes around it. The macro was trying to match the tab [[Railroad Footnotes]] which isn't a part of the macro, so the default was not working.

Damon Pritchett

unread,
Apr 30, 2020, 5:56:47 PM4/30/20
to TiddlyWiki
Thanks so much! I knew there must have been something I was doing. Works beautifully.

Did you happen to give any thought as to whether or not it's possible to use a field to set the tab state instead of a state tiddler?

Thanks,

Damon
Reply all
Reply to author
Forward
0 new messages