Example demo
To show the application of this discussion, see the Simple Pagination Two example below.
It accept a filter (with any complexity) and produces a list with a header contains alphabetical index buttons! On click the output will be limited to titles prefixed with that letter.
Code
\define simple-pagination-two(scope:"[all[tiddlers]!is[system]]")
<$let
letters = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
cond = "[all[tiddlers]] +$scope$ +[uppercase[]prefix<currentTiddler>]"
tempTid = "$:/temp/pagination"
titlePrefix = {{{ [<tempTid>get[text]] }}}
listfilter = "[uppercase[]prefix<titlePrefix>]"
selStyle = "[<currentTiddler>match<titlePrefix>then[font-weight:bold;color:red;]]"
>
<!-- create header -->
<$list filter="[<letters>split[]filter<cond>]">
<$button style="color:navy;margin:1px;width:2em;height:1.8em;cursor:pointer;">
<span style={{{[subfilter<selStyle>]}}} ><$text text=<<currentTiddler>> /></span>
<$action-setfield $tiddler=<<tempTid>> text=<<currentTiddler>> />
</$button>
</$list>
<!-- generate output -->
<$list
filter="[subfilter<__scope__>filter<listfilter>sort[title]]"
template="$:/core/ui/ListItemTemplate"
/>
</$let>
\end
To give a try
- download Simple Pagination Two.json (1.2 KB)
- drag and drop into https://tiddlywiki.com
- open Simple Pagination Two
Remarks
- Two
filteroperator is used,condandlistfilter - Note to the usecases in
filter="[<letters>split[]filter<cond>]">andfilter="[subfilter<__scope__>filter<listfilter>sort[title]]"
- Some css styles have been used as cosmetic!
Screencast
In the below an example the macro is called with
<<simple-pagination-two "[tag[Filter Operators]] [tag[Filter Run Prefix]]">>
which produces
