[Help]: Tabs, Sub-tabs and Focus on the Sub-Tabs

Hello, Guys!

I made a lot of progress in this activity management project. Also thanks to the help and support of @TW_Tones, @twMat, @pmario and others here in the tiddlywiki community. Thank you very much so far.

I came across a new difficulty. I don’t know if I will find a solution. The question is apparently quite simple. I’ve tried several ways, but as I don’t know the inner workings of Tiddlywiki well, I don’t know how to proceed.

STRUCTURE
“READING SHEET” is a sub-tiddler/sub-tab for tiddler “Areas of INTEREST” which is also a sub-tiddler/sub-tab of “ROUTE 56-35-58”.

The screenshot shows the content of “ROTA 56-35-58”. There, both the “Áreas de INTERESSE” (Areas of INTEREST) TAB appears in the horizontal TABS, as well as the “FICHA de LEITURA” (READING SHEET) SUB-TAB of the “Áreas de INTERESSE” TAB.

The QUESTION
I need to put “with code” the FOCUS [as if the “FICHA NOVA” (NEW SHEET) SUB-TAB had been clicked] on the SUB-TAB “FICHA NOVA” (NEW SHEET), that is nested within the “Áreas de INTERESSE” tiddler (Areas of INTEREST), when I click on the button: “FICHA NOVA” (NEW SHEET) in the “FICHA de LEITURA” (READING SHEET) tiddler.

ATTEMPT
I tried doing this using the parameters: “state” and “default” via $macrocall $name=“tabs” on all levels of the tiddler nest (but it seems the effect of “default” only works on your own tiddler level (remembering that they are nested tiddlers and tabs). One of the possibilities would perhaps be to use “default” in the mother tiddler “ROTA 56-35-58”. But I don’t know how to do it.


MY CODE

MOTHER TIDDLER "ROTA 56-35-58"

\define my-actions-tagtab()
<$action-setfield $tiddler="🗺 ROTA 56-35-58" $field="TAGTab" $value=<<currentTab>>/>
<$action-listops $tiddler=<<storyTiddler>> $tags="-[tags[]] +[{🗺 ROTA 56-35-58!!TAGTab}]"/>
\end

<$macrocall $name="tabs"
   tabsList="[field:SEÇÃO[🗺 ROTEIRO do DIA]has[modified]nsort[modified]]"
   actions=<<my-actions-tagtab>>
/>

SUB-TIDDLER / SUB-TABS "Áreas de INTERESSE"

<$macrocall $name="tabs"
   tabsList="[field:SEÇÃO[Áreas de INTERESSE]has[modified]!nsort[modified]]"
   default={{Áreas de INTERESSE 👀!!GuiaAtual}}
   class="tc-vertical"
/>

SUB-TIDDLER / SUB-TABS "FICHA de LEITURA"

\define my-actions-open()
<$action-setfield $tiddler="Áreas de INTERESSE 👀" $field="GuiaAtual" $value="FICHA NOVA 📚"/>
<$action-setfield $tiddler="FICHA de LEITURA 📚" $field="SEÇÃO" $value=""/>
<$action-setfield $tiddler="FICHA NOVA 📚" $field="SEÇÃO" $value="Áreas de INTERESSE"/>
\end

<$button actions=<<my-actions-open>>>
FICHA NOVA
</$button>

RESULT
When I click on the “FICHA NOVA” (NEW SHEET) button, it hides the “FICHA de LEITURA” (READING SHEET) SUB-TABS and makes the “FICHA NOVA” (NEW SHEET) tiddler appear as a SUB-TAB along with “ATÊLIE TEOLOGICO” and the “Notas de INTERESSE” SUB-TABS.

The QUESTION:
But it doesn’t display the content of “FICHA NOVA” (NEW SHEET) if I don’t click on it.
Is there a way to make the content of the “FICHA NOVA” (NEW SHEET) SUB-TABS appear, without me having to click on the tab?

Thank you very much in advance for your attention.

Cláudio Rieper

Cláudio,

Let me initially point you in the right direction. Rather than address your question in detail, but you have documented your problem well.

  • Tip number one, TiddlyWiki is using similar mechanisms to what you want to do already, and although not always easy to read a lot of answers can be found there. If you open the Control Panel you see there is a cascade of tabs there as well.
  • I like to install the “link to tabs” plugin that allows me to open individual tab tiddlers, especially while researching and coding.
  • You will see in these tiddlers the use of the state or explicitState parameters.
    • These set where to store the state of that tab set. Sometime these parameters will be set to a name like $:/state/tab-1749438307 these have come from using a <<qualify prefix>> macro then setting the value statically.
    • Each time you change tabs, this is where the current tiddler is set, and can be seen if you open the tiddler.
  • The tabs macro says the following about the default parameter;

The title of the tiddler whose tab is to be selected by default, if the state tiddler doesn’t exist. The state tiddler takes precedence over this setting

  • You can see from this the default is only used if there is no current tab set. So the default is usually seen once, then the last selected tab will always be used.
    • This should for the first time only open your nominated default
  • If you want your default to open, if you return to the wiki, rather than use the last selected tab, you can name your state tiddler beginning $:/temp/ since by Tiddlywiki default these tiddlers are not saved, so it will revert to the default.

Note;

  • Each tabs macro will need its own default and state, there is an automatic one set, but if you name them you gain more control.

Related

  • I have being looking at “improving” the tabs macro and see value in setting a variable to the name of the state tiddler, then use that in the state/explicitState parameters, using this variable the sub tabs can see this value. including those for parent tab sets etc.

Let me know if this helps you move forward.

default is only used, if state-tiddler does not exist or the state-field does not exist. So default can only be used once.

As soon as the state exists, it’s probably a state=<<qualify abc>> – So you will need to know that state name, if you want to modify it.

To find out about state tiddlers you can use [haschanged[]] in the AdvancedSearch → Filter tab

Hi, @TW_Tones and @pmario!

First, thank you very much for your feedback and research recommendations.

Could you tell me what part of this code would look like, especially the part referring to “state”? What do I believe is the way?

From what I’ve seen, it will be very difficult to decipher how the mechanism works by looking at these system tiddlers to check how "explicitState" works and how <<qualify prefix>> works.

I even looked in the documentation, but there is nowhere an example of how "explicitState" should be used, as well as <<qualify prefix>> itself. For a beginner, it is very confusing to understand how the mechanism works!

Therefore, as I already mentioned, I am still not clear on how this mechanism works and stores this information.

There is still one question. From what I understand, I believe I should save and define the “state” of the “tabs” macrocall. But at what level should I do this? In the MOTHER TAB or SUB-TAB “READING SHEET”, where is the “NEW SHEET” button?

Thanks in advance for your attention.

If you read the documentation here tabs macro this macro provides a state parameter which is defined as;

state
The prefix for the title of a state tiddler for noting the currently selected tab, defaulting to $:/state/tab. It is recommended that this be a system tiddler

  • This is a prefix that receives further processing, presumably using the qualify macro or similar, see the explicit state tyhat tells you this.

explicitState
Optionally, an explicit state title can be specified. It will be preferred over the internally computed (qualified) state title

  • here you provide the whole tiddler title, for the state tiddler, this would be useful of you wanted a global setting.
  • You could make explicitState resemble state by using the qualify macro eg
    • explicitState=<<qualify prefix>>

Now however the tabs macro obtains the state tiddler title, each click on a tab saves that tabs tiddler title in the state tiddler.

  • If your tabs are only ever visible in one tiddler you can just use a simple tiddler title eg $:/state/mytabs

A few more tips;

  • You can make use of the actions parameter in the tabs macro but keep in mind there already is one action in place, that is each tab is actually a button that looks like a tab and clicking that changes to the state tiddler to the currentTab.
    • Thus if you understand the default behaviour you may be able to simplify this.

@Claudio_Rieper I am sorry about the delay in my response, I have being busy and I am interested in a more complete solution. The above is a simple answer.

Here is some further thinking on my part and some examples that may help you come to grips with the use of tabs.

My current thoughts;

  • If you set a variable to the name of the state tiddler and use that in the explicitState parameter not only does the tabs macro have access to the title of the state tiddler but so do any tabs within that, by reference to the variable.
    • Remember however if you have nested tab sets each set needs its own state tiddler.

For example;

<$let mystate="$:/state/test-tabs">

<$macrocall $name=tabs tabsList="[tag[TableOfContents]]" explicitState=<<mystate>> template=test-tab-template/>

</$let>

Please find attached two tiddlers you can look at on tiddlywiki.com and the result of the tabs.

mytabs.json (807 Bytes)

With my examples above now you have a known state tiddler title it is simply a matter of setting that to the tab you want displayed, either inside the tabs or outside the tabs

  • where the mystate variable is not available) you may need to provide it.
<$button setTitle="$:/state/test-tabs" setTo=About>About</$button>
  • If the tabs that use this state are visible it will change to the specified tab, if the tab named is invalid nothing will be selected. - works with above examples

In the following example it will also open or navigate to the tiddler containing the tabs - works with above examples.

<$button to="Test tabs" setTitle="$:/state/test-tabs" setTo=About>About</$button>

In closing;

  • I think all the information you need is contained in these notes, but you also get a little deeper knowledge in the process and will be worth the investment in time.
  • Have a go and share a simple example that works/or does not work, we can use on TiddlyWiki.com.
  • Things get harder to follow when there are multiple subtabs, so if you share an example please keep it as simple as you can.
    • For example give the tabs single word tiddler titles, you can also set the caption later.