HELP: TAGS and TABS

Hello guys!

DIFFICULTY: Can anyone tell me how to create a TIDDLER with the TABS macro and assign a different TAG to the Current TIDDLER (in the TIDDLER where the TABS are displayed) each time the “selected TAB” changes. Or put another way, apply/toggle a “different TAG” for each clicked TAB.

Looking at the original TIDDLYWIKI website, I imagine that this would be done optionally through the “actions” parameter, but searching the documentation and the internet, I didn’t find any example that demonstrates how to do this.

<<tabs “SampleTabOne SampleTabTwo SampleTabThree” “SampleTabTwo” “$:/state/tab2” “tc-vertical”>>

Unfortunately my lack of experience with TIDDLYWIKI prevents me from being able to correctly assemble this command or other operation to achieve this goal.

Thanks in advance for everyone’s attention.

This worked when run from a tiddler at tiddlywiki.com.

\define actions() 
<$action-listops $tiddler=<<save-currentTiddler>> $field="tags" $subfilter="-[tags[]] +[<currentTab>]"/>
\end
<$macrocall $name="tabs" tabsList="SampleTabOne SampleTabTwo SampleTabThree SampleTabFour" default="SampleTabOne" state="$:/state/tab1"
actions=<<actions>>
/>
1 Like

It depends on what you intend the tag to mean and how you name it. The state is changed when you select the tab to the currenttab perhaps that is helpful. There is also the posibility to make your own tab template that uses currenTab variable.

One question is do you want it to remove a tag from another tab at the same time?

“tabs” are actually built up of buttonwidgets and revealwidgets. So it is probably simpler to just use a couple of these widgets directly and style them to get what you want.

Or consider the checkboxwidget which has really made toggling of tags super simple and use a listwidget to reveal the “tab content” if the current tiddler has the tag. Checkboxwidgets can also be styled to appear anyway you want .

I think it would be better to describe what you want to achieve instead asking for a new feature. The request makes me think there are different … more tiddlywiki like ways to achieve what you want. …
Just a thought

1 Like

@mark_s’s solution is 99% correct, but needs just a little tweak to exactly fit the OP request:

<$let here=<<currentTiddler>>>
<$macrocall $name="tabs"
   tabsList="SampleTabOne SampleTabTwo SampleTabThree SampleTabFour"
   default="SampleTabOne"
   state={{{ [[$:/state/tab/]addsuffix<here>addsuffix<qualify>] }}}
   actions="""<$action-listops $tiddler=<<here>> $tags="-[tags[]] +[<currentTab>]"/>"""
/>

Notes:

  • $let here=<<currentTiddler> holds the title of the current tiddler for later use
  • A unique state parameter value is constructed using the current tiddler title and a TWCore <qualify> macro
  • The actions parameter is specified “inline” to avoid extra macro definition “pollution”
  • $action-listops targets <<here>> (the “current tiddler”, as specified in the OP)
  • $action-listops uses $tags=... param instead of more verbose $field=... and $subfilter=... params

enjoy,
-e

2 Likes

Instead of creating a variable for storing the value of <<currentTiddler>>, you could use <<storyTiddler>>, seems to works

<$macrocall $name="tabs"
   tabsList="SampleTabOne SampleTabTwo SampleTabThree SampleTabFour"
   default="SampleTabOne"
   state={{{ $:/state/tab/[<storyTiddler>]+[join[]] }}}
   actions="""<$action-listops $tiddler=<<storyTiddler>> $tags="-[tags[]] +[<currentTab>]"/>"""
/>

I also did some research out of curiosity and discovered that it is not necessary to use qualify, the tab macro already does it:

\define tabs(tabsList,default,state:"$:/state/tab",class,template,buttonTemplate,retain,actions,explicitState)
\whitespace trim
<$qualify title=<<__state__>> name="qualifiedState">
..
2 Likes