Hi, I’m working on a tiddler that I’d like to put in the siebar that shows the last N tiddlers I’ve closed (the number N is any reasonable number. To simplify the question I’ll use 3 here).
I apologize if what I wrote seems long but I thought I’d explain in detail to avoid misunderstandings
How it would work:
1. I create a button similar to $:/core/ui/Buttons/close
(you could also override it, but I prefer not) which has the exact same code except for two new actions it performs when closing the tiddler:
- an
$action-setfield
which gives the name of the tiddler just closed to a field as a value - another
$action-setfield
witch updates a value on a counter (and here I am having difficulty)
2. Another tiddler, the one I’m changing the fields to, (and the one I’m going to put in the SideBar) shows the titles of the last closed tiddlers as links, taking them from its fields. For now I accomplish this in this way:
<$link to={{RecentlyClosed!!slot_1}}/><br>
<$link to={{RecentlyClosed!!slot_2}}/><br>
<$link to={{RecentlyClosed!!slot_3}}/><br>
Btw I’m planning to make the list change order based on the counter, so to have the most recendly closed tiddler on the top and the least recently closed at the bottom. (although I have no idea how to do it, but one thing at a time)
So, here’s what happens:
-
- I click the custom button to close the tiddler
-
- the button as well as closing the tiddler performs these actions:
Assign-slot > The title of the tiddler closed is stored a field of the tiddler “RecentlyClosed” (the default field is “slot_1” because the default value of the counter field is “slot_1”)
\define Assign-slot()
<$action-setfield $tiddler="RecentlyClosed" $field={{RecentlyClosed!!counter}} $value={{!!title}}/>
\end
Update-slot > In order to store more titles, the next field (slot) that will hold the next title needs to be upgraded, so the “counter” field needs to be modified
\define Update-slot()
<$action-setfield $tiddler="RecentlyClosed" $field="counter" $value=???slot_2???/>
\end
Not knowing what to put as value I put some “???” in the code above.
But what this counter is supposed to do is:
-
If its own value = “slot_1”, replace it with “slot_2”
-
If its own value = “slot_2”, replace it with “slot_3”
-
If its own value is different from “slot_1” and “slot_2”, replace it with “slot_1”
(in this way I take into account both “slot_3” and any possible error in the value of the field)
(It can also be done with more than 3 slots, the progression is simple.)
- - Now that the title is stored and the counter field points to a different field, I can store titles up to the number N that I have chosen, to then be able to start the cycle again.
I think I should (maybe) use a filter operators so to use if-then-else logic, but I don’t know how to express what I wrote above (and I don’t know how to insert it instead of the ??? in the $value= of the Update-slot)
How can I make this “counter” work? (or rather, the Update-slot)