[TW5] Tabs Macro - alt names for tabs

926 views
Skip to first unread message

Hegart Dmishiv

unread,
Jan 27, 2016, 4:33:35 PM1/27/16
to tiddl...@googlegroups.com
Hi all,

I'm wanting to use the tabs macro to create a list of tabs in a tiddler, but I want to display alternate text on each tab, rather than just the name of the tiddler that the tab is linked to. For example (note that this doesn't work, but you'll get the idea of what I'm trying to do here)..

<<tabs "[[Notes|Notes about this tiddler]] [[Quotes|Quotes pulled from this tiddler]] [[Summary|The summary of this tiddler]]" "[[Notes|Notes about this tiddler]]" "$:/state/this-tiddler-tabs">>

What I want to see is a row of tabs titled Notes | Quotes | Summary but which link properly to the appropriate child tiddlers. Is this possible?

Thanks,
Hegart.

Hegart Dmishiv

unread,
Jan 27, 2016, 4:38:26 PM1/27/16
to TiddlyWiki
Oh, sorry, ignore me. RTFM.

"The tabs display the caption field of a tiddler if it has one..."

Hegart Dmishiv

unread,
Jan 27, 2016, 4:56:29 PM1/27/16
to TiddlyWiki
Actually, this is still an issue for me. I've tried using the caption tiddler field as suggested, and it works nicely for this, except that it has other, more wide-ranging ramifications within my TW instance. It seems that setting a caption will affect the tiddler's title as displayed in lists, such as in my TOC and any other lists. So now, rather than having a list that looks like this...
  • Notes about tiddler foo
  • Notes about tiddler bar
  • Notes about tiddler baz
... I now have a list looking like this...
  • Notes
  • Notes
  • Notes
That's not really very helpful. Is there some way to achieve what I'm after, setting alternate names as the titles of tabs, without using the caption field?

Hegart Dmishiv

unread,
Jan 27, 2016, 5:15:22 PM1/27/16
to TiddlyWiki
Again, I have worked this out for myself. Sorry for spamming up the forums with my thoughts as I go. I created a shadow tiddler for $:/core/macros/tabs and I modified line 7 of it to read...

<$transclude tiddler=<<currentTab>> field="tabcaption">

Now I just set a tabcaption field in the tiddlers that I want to use as tab headings, and it doesn't touch the caption field at all. Have I inadvertently caused myself any problems by doing this? I'm really not confident yet with shadow tiddlers, or macros for that matter. ;-)

Hegart Dmishiv

unread,
Jan 27, 2016, 5:40:25 PM1/27/16
to TiddlyWiki
Oh dang! I stuffed up everything else that relies on the Tabs Macro, didn't I? Oh well, you live and learn. I guess I'll have to make a copy of the Tabs Macro, make my change to the copy instead, and return the default one to the way it was.

Hegart Dmishiv

unread,
Jan 27, 2016, 6:32:49 PM1/27/16
to tiddl...@googlegroups.com
I've almost got this working, but I may need some help with the final step. I've copied the core tabs macro to $:/_Macros/reftabs and did a quick search & replace to swap all occurrences (case-sensitive) of tab with reftab and it seems to be working okay. However, it defaults to button view, rather than viewing the tabs as actual tabs (example). I guess this is a coding issue beyond my mere copypasta skills. Could anyone point me in the right direction here please?

I could use it as is, but it would look nicer if the tabs were, you know, tabs! ;-)

BJ

unread,
Jan 28, 2016, 2:13:04 AM1/28/16
to TiddlyWiki
Hi Hegart,

you have also renamed the css classes to non-defined values:

<div class="tc-reftab-set $class$">

you need to put back the original css class name eg  tc-tab-set in the above and elsewhere


all the best
BJ

Hegart Dmishiv

unread,
Jan 28, 2016, 2:39:35 AM1/28/16
to TiddlyWiki
Hi BJ,

yep, that was the answer, thanks for that. I still can't look at code (in general) and figure out for myself what it is doing. At least, not much. I'm getting there though. Thanks again for your help.

Hegart.

Tobias Beer

unread,
Jan 28, 2016, 5:19:18 AM1/28/16
to TiddlyWiki
Hi Hegart,

You can very well just modify the core tabs macro!

The way both the TranscludeWidget and ViewWidget work is that
you can define fallback content as their innner content like so:

<$transclude field="my-tab-caption">
<$transclude field="caption">
<$view field="title"/>
</$transclude>
</$transclude>

Best wishes,

Tobias.

Scott Simmons (Secret-HQ)

unread,
Jan 28, 2016, 7:38:21 AM1/28/16
to tiddl...@googlegroups.com
Hi, Hegart —

I have a similar situation to yours and arrived at pretty much the same solution.  I use certain tiddlers as tab contents in different places; in some places, I want to the tab to have one name, and in others I want it to have another name.

So I cloned the tabs macro shadow tiddler and created the <$tabs-altCaptions> macro.  I just give my tiddlers an additional field (caption_alt) and, when I want to create a set of tabs using that field for tab titles, invoke:

<<tabs-altCaptions>>

rather than the core macro <<tabs>>.

Inelegant perhaps, but it does the trick!

I'm attaching the .TID file in case anyone wants it.


Also, if you're as tab-happy as I am, check this out:


It is the greatest thing since sliced bread.  ;)


On Wednesday, January 27, 2016 at 5:15:22 PM UTC-5, Hegart Dmishiv wrote:

Again, I have worked this out for myself. Sorry for spamming up the forums with my thoughts as I go.

All the best threads are like that!

Sometimes typing it out makes you realize where you've gone wrong, and there's nothing I appreciate more than being able to read through someone's process and see how they got something to work — especially if I'm wrestling with the same issue when I come across their post.  I wish more people would take time to follow up on their posts when they solve something themselves.
$--macros-secret-hq-tabs-alternate captions.tid

Hegart Dmishiv

unread,
Jan 28, 2016, 3:37:19 PM1/28/16
to TiddlyWiki
Hi Tobias and Scott,

So, in my shadow tiddler for $:/core/macros/tabs I could have simply inserted a new line between lines 7 and 8, adding the <$transclude field="tabcaption"> code, then close it with a </$transclude> under the existing line 8 (which would become line 9 after my first insert). Okay, that's handy to know, thanks for that Tobias.

Nice to see someone else came up with the same solution I did, Scott. I see in your macro, line 7 contains your caption_alt field. Very cool. Is there any advantage of one method over the other, of using a shadow tiddler versus copying the core macro contents to a whole new macro as we did?

Hegart.

Tobias Beer

unread,
Jan 29, 2016, 5:14:17 AM1/29/16
to TiddlyWiki
Hi Hegart,
 
Nice to see someone else came up with the same solution I did, Scott. I see in your macro, line 7 contains your caption_alt field. Very cool. Is there any advantage of one method over the other, of using a shadow tiddler versus copying the core macro contents to a whole new macro as we did?

The one advantage is that your changes also apply to any tabs rendered via the core. So you can use your "my-tab-caption" field with any tiddler and see it work with the core macro, without having to point to a different macro. But, that entirely appears to be a matter of preference. It sure ain't a bad decision to leave core components as-is and have updates do their thing... and to create your own variant(s). I just wanted to point out that you don't have to. In fact, I think your proposition should be a pull request to the core. Because, wherever captions are used, it is nice to see them be generic, but there are plenty cases where you need a use-case specific caption and not a generic one, as you rightfully pointed out.

Best wishes,

Tobias.

Hegart Dmishiv

unread,
Jan 29, 2016, 5:53:20 AM1/29/16
to TiddlyWiki
Hi Tobias


The one advantage is that your changes also apply to any tabs rendered via the core. So you can use your "my-tab-caption" field with any tiddler and see it work with the core macro, without having to point to a different macro.

Ah, I see, thanks for explaining that.
 
In fact, I think your proposition should be a pull request to the core. Because, wherever captions are used, it is nice to see them be generic, but there are plenty cases where you need a use-case specific caption and not a generic one, as you rightfully pointed out.

If that happens, I assume the "my-tab-caption" field, or whatever it will be called, will need to come under some sort of naming policy. I'll leave the PR to you, as you're more familiar with the nomenclature for naming core (and plugin) variables etc. I'm sure I saw you discussing such, recently, but I just can't find a link to it.

I probably could do the PR myself, but I wouldn't know what to name the field, if it is going to be distributed widely in the TW core.

Thanks again for suggesting this. I'm sure Steve Schneider would also be pleased to know that something from one of his class exercises might make it into the core in a future version of TiddlyWiki.

Hegart.

Hegart Dmishiv

unread,
Jan 29, 2016, 6:28:36 AM1/29/16
to TiddlyWiki
Actually, I've just notice a minor hitch with this. I can't seem to get the default parameter ("The title of the tiddler whose tab is to be selected by default") to work in my customised version of the tabs macro. I tried passing it both the tiddler title in [[square brackets]], and also the value of the tabcaption field, but the default tab is not opening when the tiddler is opened.

My example here uses the former (the square brackets option) and my example here uses just the value of the field instead. Neither of them have a default tab open when the tiddler is opened. Clicking on the tabs works fine, however.

Does your customised macro exhibit the same behaviour, Scott?

Tobias Beer

unread,
Jan 29, 2016, 6:30:54 AM1/29/16
to TiddlyWiki
Hi Hegart,
 
I probably could do the PR myself, but I wouldn't know what to name the field, if it is going to be distributed widely in the TW core.

I'm not sure but I believe those "conventions" boil down to preferences. So, it's all about giving it some thought, proposing a change... and then have an actual "code-base" / pull request to talk over modifications such as "let's better use this name, rather than that one". Tbh, I am not sure what those conventions are when it comes to field-names or if there really are any (yet).

All I'm saying is that you can literally propose changes to core macros as you can propose changes to the core documentation. The process is very much the same, if you so wish.
 
Thanks again for suggesting this. I'm sure Steve Schneider would also be pleased to know that something from one of his class exercises might make it into the core in a future version of TiddlyWiki.

Ah, interesting. Didn't know that was the background. Glad to see his course catch (your) interest. I have to admit, I haven't taken much time yet to actively part-take in any of it. I very much like the slightly more scientific setting so as to explore the TiddlyWiki ecosystem and habitat in all its expressions from a duly conceptual / analytical perspective... while doing practical and quite useful exercises for it all ...such as this one.

I'm sure the goal of it is not to birth "TiddlyWiki developers"... but perhaps it helps people see that the process of that truly is just that: doing the desired changes while coming to terms with why and what and how to do it. Could just be a part of your note-taking process... but could also be a little something that ends up benefiting the community at large.

So, I think, this kind of "contributors-mindset" is very welcome and worth nourishing. It's not so much a privilege to do the "actual developing"... but rather something you dare undertake, exposing your ideas and solutions to the scrutiny, eventually of the one(s) who designed the core aspects of the ecosystem.

For what it's worth, I am pretty confident there already is (/are) some GitHub issue(s) about the topic of (more use case oriented) captions... for you to chime in, if you so wish. Contributions need not always be in the form of code, but can just be a distillation of an idea ...only later turned in to code.

Take Mat's federation. He had that hunch, as he often does, coupled with plenty excitement as well as persistence... and eventually it lead to the advent of it all, even if he may not have aspired for any code contributions on his end.

As said elsewhere, there are those that just go play ...with ideas ...and then some to work out the whys and then those that formalize the whats and eventually those that figure out all the hows. All of these steps are important by themselves and having them be impersonated by one guy is quite a rarity, cough Jeremy. ;-)

Best wishes,

Tobias.

Tobias Beer

unread,
Jan 29, 2016, 6:40:03 AM1/29/16
to TiddlyWiki
Hi Hegart,

 
Actually, I've just notice a minor hitch with this. I can't seem to get the default parameter ("The title of the tiddler whose tab is to be selected by default") to work in my customised version of the tabs macro. I tried passing it both the tiddler title in [[square brackets]], and also the value of the tabcaption field, but the default tab is not opening when the tiddler is opened.

Allow me to quote from the tabs Macro documentation:

default
The title of the tiddler whose tab is to be selected by default

 Best wishes,

Tobias.

Hegart Dmishiv

unread,
Jan 29, 2016, 4:50:35 PM1/29/16
to TiddlyWiki
Hi Tobias,


Allow me to quote from the tabs Macro documentation:

Oh derp! Thanks for pointing that out. I'm so used to having to enclose titles which have spaces in them with square brackets. I take out the square brackets from the default parameter and voila!

I've had a go at a pull request, but I'm not sure if I've done this correctly.

#4b528a5 Added optional tab-caption as a fallback field

I think that is just a commit to my fork of Jeremy's repo though. Sorry, I'm still not really all that confident with GitHub.

Hegart.

Tobias Beer

unread,
Jan 30, 2016, 4:24:16 AM1/30/16
to TiddlyWiki
Hui Hegart,
 
I've had a go at a pull request, but I'm not sure if I've done this correctly.

#4b528a5 Added optional tab-caption as a fallback field

Great. 

I think that is just a commit to my fork of Jeremy's repo though. Sorry, I'm still not really all that confident with GitHub.

Nonone expects things to be perfect the fist time around.
I think it's great you did this important "first" step to see how the experience unfolds.

Best wishes,

Tobias.

Hegart Dmishiv

unread,
Jan 30, 2016, 5:21:19 AM1/30/16
to TiddlyWiki
Hi Tobias,

Do I need to do something else to get that PR into Jeremy's pull requests list? It's not showing up there yet. I did that one PR before Christmas, for something minor in the TW documentation, but I can't remember what it was I did to get that one into the PR list. I feel like a fraud, with Jeremy having included me in the "contributors" list for the v5.1.10 release, just for that. ;-)

Hegart.

Scott Simmons (Secret-HQ)

unread,
Jan 30, 2016, 6:57:49 PM1/30/16
to tiddl...@googlegroups.com
On Thursday, January 28, 2016 at 3:37:19 PM UTC-5, Hegart Dmishiv wrote:

Nice to see someone else came up with the same solution I did, Scott

"GMTA," as they say.  ;)
 
I see in your macro, line 7 contains your caption_alt field. Very cool. Is there any advantage of one method over the other, of using a shadow tiddler versus copying the core macro contents to a whole new macro as we did?

Well, the existing macro is a shadow tiddler, so if we changed and saved it, we'd effectively "overwrite" the shadow, leaving our TiddlyWiki with only the new <$tabs> macro we just created.  I decided to clone the core macro and give it a new name so that the basic <$tabs> from the core would still be available.  That way, if <$tabs> gets major updates in the core somewhere down the line, I'll be able to see them in my regular tabsets — and adjust my home-baked <$tabs-altCaptions> macro accordingly.

Best of both worlds, in my opinion!  ;)
Reply all
Reply to author
Forward
0 new messages