How reference specific tab in a tiddler?

57 views
Skip to first unread message

Amzg

unread,
Jun 24, 2008, 7:26:20 PM6/24/08
to TiddlyWiki
I have a two tiddlers, A and B, each with two tabs; tabA1 tabA2 and
tabB1 and tabB2.

In A the tabs are defined by;
<<tabs referencelabel [[tabA1]] "tooltip1" [[subtiddlerA1]] [[tab2]]
"tooltip2" [[subtiddlerA2]] >> ... and equivalently in for B.

First question:
In normal viewing mode (i.e non-edit) I click on a link (not a tab) in
A, tabA1 and that makes the view switch over to tabA2. What is the
syntax for this link? (Or is required to i.e not open a new tiddler
for this?)

Second question:
In normal viewing mode I click on a link in any tab in A and this
opens tiddler B with tabB2 active. What is the syntax for this link?


Backround: Tiddlyspot.com offers free hosting for TW's and one
excellent template there is for "Presenations". Briefly, this is a TW
showing only one tiddler at a time. I found this made my presentation
too long, so I decided to try out using tabs. I'm unsure of how to
make a link open a full tiddler rather than merely the tab-specific
tiddler... and if 'Presentations' perhaps interfer with this because
it has some kind of "show one tiddler at a time only" setting.


Thank you in advance!!!

/Mat

FND

unread,
Jun 25, 2008, 5:01:46 AM6/25/08
to Tiddl...@googlegroups.com
If I understand this correctly, you want to open a specific tab without
using the actual tab buttons.
This isn't easily possible. You might be able to write a macro using the
core's switchTab() function though...


-- F.

Amzg

unread,
Jun 25, 2008, 7:37:21 AM6/25/08
to TiddlyWiki
Yes, that was my intention. I was hoping for something along the lines
of a link "[[A:referencelabel:tabA1]]" (ie. referencelabel being the
label specified in the macro).

Thanks for your answer.

/Mat

Eric Shulman

unread,
Jun 25, 2008, 11:40:36 AM6/25/08
to TiddlyWiki
> Yes, that was my intention. I was hoping for something along the lines
> of a link "[[A:referencelabel:tabA1]]" (ie. referencelabel being the
> label specified in the macro).

The 'tabset ID' (which you call a 'referencelabel') is used to track
the current opened tab within a given tabset, by saving the text of
the currently displayed tab (e.g., "TabA1", "TabA2", etc.) using a
core config.options.* internal variable.

For example, if you write:
<<tabs someID "tab A" "..." [[TiddlerA]] "tab B"
"..." [[TiddlerB]]>>
The current tab text ("tab A" or "tab B") will be stored in
config.options.someID

Note: if the ID begins with "txt" (e.g., "txtSomeID"), it is
automatically saved as a cookie value in addition to being tracked
internally, so that the last opened tab is always redisplayed whenever
that tiddler is opened.

Normally, this tracking value is only set when you actually click on a
tab. However, you could use HTML syntax to construct a special link
that sets this value as part of the 'onclick' handler for the link, so
that when the tiddler containing the tabset is displayed, the desired
tab is opened, like this:

<html><a href='javascript:;' onclick='config.options.tabID="some tab";
story.displayTiddler(story.findContainingTiddler(this),"SomeTiddler");
story.refreshTiddler("SomeTiddler",null,true);'>SomeTiddler</a></html>

(note: omit all newlines from the above... it should be *one* line
only)

The first statement of the onclick handler sets the desired tab in the
internal core variable, and the second statement opens the tiddler
containing the tabset. If the tiddler was *not* previously displayed,
that is all you need. However, if the tiddler *was* already being
displayed, then you must also ensure that tiddler is re-rendered so
the correct tab will be shown. That is what the third statement does.

Also, to make it much easier to repeatedly embed the above syntax, you
can use
http://www.TiddlyTools.com/#AliasPlugin
to define an 'instant macro':

<<alias tabLink [[<html><a href='javascript:;' onclick='config.options.
%1="%2"; story.displayTiddler(story.findContainingTiddler(this),"%0");
story.refreshTiddler("%0",null,true);'>%0</a></html>]]>>

which you can then use like this:

<<tabLink "SomeTiddler" "someLabel" "some tab">>

enjoy,
-e

Amzg

unread,
Jun 26, 2008, 3:38:37 PM6/26/08
to TiddlyWiki
That is an incredibly thorough answer THANK YOU SO MUCH. Needless to
say I would never have solved this alone.

I can't quite get that triple html statement (all on one line) to work
though;

<html><a href='javascript:;' onclick='config.options.tabID="TabA2";
(i.e TabA2 being the actual tabs name defined in TiddlerA, not the
tabset ID (tabIDTiddlerA). And I also keep the quote signs.
Also I notice both a colon and a semicolon after the word javascript.
All correct?)

story.displayTiddler(story.findContainingTiddler(this),"TiddlerA");
story.refreshTiddler("TiddlerA",null,true);'>TiddlerA</a></html>

OR, maybe I misunderstand the supposed effect? Implementing the above,
results in a link TiddlerA. Clicking on it opens TiddlerA but with
TabA1 active. Also if TiddlerA is already opened, clicking the tiddler
with the code still merely activates TiddlerA but with whatever tab
active remaining.


Thank you!

/Mat

Eric Shulman

unread,
Jun 26, 2008, 4:05:26 PM6/26/08
to TiddlyWiki
> <html><a href='javascript:;' onclick='config.options.tabID="TabA2";
> (i.e TabA2 being the actual tabs name defined in TiddlerA, not the
> tabset ID (tabIDTiddlerA). And I also keep the quote signs.
> Also I notice both a colon and a semicolon after the word javascript.
> All correct?)

You need to use the *matching* tabset ID in the assignment, like this:

config.options.tabIDTiddlerA="TabA2"

-e
Reply all
Reply to author
Forward
0 new messages