Open a tab by clicking on the link

Hi! Is there a way to make a standard link open a tab of the same tiddler?
I am sorry if this question was answered before, I tried to formulate it in different ways and couldn’t find anything. Thank you!

Perhaps explain what you want in a little more detail.

Whilst you say standard link need it only look like one?, or must it be [[tiddlername]] there may be dozens of ways to achieve what you want but I am not exactly sure what you want.

I’ll try! Let’s say I have a tiddlerA that includes tiddlerB and tiddlerC as tabs, so it calls <<tabs "tiddlerB tiddlerC" "tiddlerB">>. I would like to include in a text of tiddlerA a link, as you said something that will look like what[[tiddlerC]] produces, but instead of opening the tiddlerC itself just opens the corresponding tab in tiddlerA. Thanks a lot for any clue.

Try this:

\define tab-link(tid)
<$let state={{{ [[$:/state/tab/TiddlerA]addsuffix<qualify>] }}}>
<$button class="tc-btn-invisible tc-tiddlylink">
   <$text text=<<__tid__>>/>
   <$action-setfield $tiddler=<<state>> text=<<__tid__>>/>
</$button>
\end

<<tab-link TiddlerB>>
<<tab-link TiddlerC>>

<<tabs "TiddlerB TiddlerC" "TiddlerB" "$:/state/tab/TiddlerA">>

Notes:

  • The <<tabs>> macro automatically adds a <<qualify>> suffix to the specified state tiddler title (i.e., $:/state/tab/TiddlerA in this example).

  • If the above content is transcluded (e.g, by using “{{TiddlerA}}” into another tiddler), then each transclusion instance will have a different generated <<qualify>> value added to the state tiddler title.

  • Thus, the tab-link macro also appends the <<qualify>> macro to the state tiddler title in order to update the correct state tiddler value.

enjoy,
-e

7 Likes

Thank you, Eric! it doesn’t look simple at all to me for now, probably it’s time to dive in more technical docs, like state mechanism and qualify widget.
Daria

@dmikh Erics solution should be simple to make use of without you knowing how it works;

Place the following in a tiddler tagged $:/tags/Macro;

\define tab-link(tid)
<$let state={{{ [[$:/state/tab/TiddlerA]addsuffix<qualify>] }}}>
<$button class="tc-btn-invisible tc-tiddlylink">
   <$text text=<<__tid__>>/>
   <$action-setfield $tiddler=<<state>> text=<<__tid__>>/>
</$button>
\end

Then in the tiddler where you want it to show, or a view template if you know how; use the macro as Eric suggested.

<<tab-link TiddlerB>>
<<tab-link TiddlerC>>

<<tabs "TiddlerB TiddlerC" "TiddlerB" "$:/state/tab/TiddlerA">>
  • There are many things I use that I don’t understand, however this is reducing.
1 Like

Hi! It’s true it works, I adapted it a little to pass to the macro the parameter for the text of the link.

\define tab-link(tid, linkText)
<$let state={{{ [[$:/state/tab/'TiddlerA']addsuffix<qualify>] }}}>
<$button class="tc-btn-invisible tc-tiddlylink">
   <$text text=<<__linkText__>>/>
   <$action-setfield $tiddler=<<state>> text=<<__tid__>>/>
</$button>
\end

You are right, things work also without our understanding, but being a beginner with TW and new to programming in general, I am still not used to it. A kind of charachter trait.

Not an uncommon trait :nerd_face: , welcome to the community, we love “fresh blood”.