Is there a way to assign a generated list to a field? Next/Previous navigation between ToC chapters attempt.

96 views
Skip to first unread message

Vayu Asura

unread,
Aug 3, 2017, 1:43:51 PM8/3/17
to TiddlyWiki
When I try this:

<$button> <$action-setfield list={{{[tag[mytag]]}}}/>Set List </$button>


I get the first list item into list field. Is there a way I can get all the titles into list field? I need it for next[] and previous[] operators. They require hard-coded list field to work properly, I'm looking for a way to at least generate this hard coded value. 

As for what I need it for, I've made this little monster to navigate between ToC chapters sequentially. 

It requires all the chapters to be in the list field of the tiddler it's called from. 

Haven't found any complete solution so built one myself. If there is a more reasonable way to do it esp without hard-coded lists, I'm very open to suggestions. 

$sel$ is the state tiddler for ToC selection (current item variable for all intents and purposes...), the reveals hide navigation when no item is selected - have tried to monitor filter state to hide when there is no next or prev item but couldnt bind it to current $sel$ tiddler value correctly.

\define TocNav(sel:"TovTest")


<$set name=selection value=$sel$>
<$set name=selectionValue value={{$sel$}}>


<!-- Debug


$sel$


<<selection>>


<<selectionValue>>


selection prev
: {{{[<selectionValue>previous<currentTiddler>]}}}


<<selectionValue>>


selection
next: {{{[<selectionValue>next<currentTiddler>]}}}


Debug !--->


<$reveal type="nomatch" state=<<selection>> text="">
<div>
<$button>
<$action-setfield $tiddler=<<selection>> text={{{[<selectionValue>previous<currentTiddler>]}}} />
<$action-navigate $to=<<currentTiddler>>/>
{{$:/
core/images/chevron-left}}
</$button>


<$button><$action-navigate $to=<<currentTiddler>>/
>{{$:/core/images/chevron-up}}
</$button>


<$button>
<$action-setfield $tiddler=<<selection>> text={{{[<selectionValue>next<currentTiddler>]}}} /
>
<$action-navigate $to=<<currentTiddler>>/>
{{$:/
core/images/chevron-right}}</$button>
</div>


</
$reveal>


</$set>
</
$set>


\end


Mark S.

unread,
Aug 3, 2017, 2:32:28 PM8/3/17
to TiddlyWiki
For the first part of your question, wrapping it with a set widget, like

<$set name=mylist filter="[tag[mytag]]">

<$button> <$action-setfield list=<
<mylist>>/>Set List </$button>
</$set>

Good luck,
Mark

Thomas Elmiger

unread,
Aug 3, 2017, 3:23:08 PM8/3/17
to TiddlyWiki
A previous/next navigation based on a tag I use can be found here: https://groups.google.com/d/msgid/tiddlywiki/722d5b9a-1d21-4342-8f95-3c6c70861dbe%40googlegroups.com

Not sure where your attempt differs from this …

All the best,
Thomas

Eric Shulman

unread,
Aug 3, 2017, 4:00:13 PM8/3/17
to TiddlyWiki
On Thursday, August 3, 2017 at 10:43:51 AM UTC-7, Vayu Asura wrote:
...
next[] and previous[] operators... require hard-coded list field to work properly
...
If there is a more reasonable way to do it esp without hard-coded lists, I'm very open to suggestions. 

before[] and after[] filters work like previous[] and next[] but use the current filter result instead of a hard-coded list.

Perhaps something like this will fit your needs:

<$list variable="parent" filter="[all[current]tags[]limit[1]]">
   <$list filter="[title
<parent>tagging[]before<currentTiddler>]">
      prev:
<$link><<toc-caption>></$link>
   </$list>
   <$list filter="[title
<parent>tagging[]after<currentTiddler>]">
      next:
<$link><<toc-caption>></$link>
   </$list>
</$list>

Notes:
* the outer <$list> assumes that the first tag on the current tiddler is the "parent" (a common usage for the <<toc>> macro)
* the inner <$list> uses the tagging[] filter to get the siblings from the parent, followed by the before[] or after[] filter to find the previous/next sibling of the current tiddler

let me know how it goes...

enjoy,
-e
Eric Shulman
TiddlyTools.com: "Small Tools for Big Ideas" (tm)
InsideTiddlyWiki: The Missing Manuals


Vayu Asura

unread,
Aug 4, 2017, 9:36:47 AM8/4/17
to tiddl...@googlegroups.com
Managed to make it work with two modifications:

<$list variable="parent" filter="[all[current]tags[]!limit[1]]">
   <$list filter="[title<parent>tagging[]before<currentTiddler>sort[list]]">
      prev: <$link><
<toc-caption>></$link>
   </$list>
   <$list filter="[title
<parent>tagging[]after<currentTiddler>sort[list]]">
      next: <$link><
<toc-caption>></$link>
   </$list>
</$list>

For some reason limit[1] yields the last tiddler not the first and my toc is sorted by list field

I don't understand what `variable` list widget parameter is generally doing (or specifically here either...). Does it just declare a variable and puts filter result into it? Do you just separate and abstract the common filter part with it or is it for something else? I have two tags on a tiddler I call it from. When I transclude it within the list it yields the resulting tag, but when I remove the !limit[1] part it regenerates both inner lists for each of two resulting tags. Wierd. Does it work as an iterator of sorts?

Not exactly what I had in mind as this requires the thing to be present on every entry rather than on the toc tiddler. But I'll try to adapt your solution to that as well and post here what I manage. The downside I see is that it can't get one level below into the expanding chapters. 

Thanks!
Reply all
Reply to author
Forward
0 new messages