Making a list paging procedure

I dont know what is the difference between Procedure/Widget in TiddlyWiki
but I use the Procedure to make list paging feature and its works fine

This is my first Procedure
If there is any shortcomings, please give me some suggestions.

first step, should add a new Tiddler for list paging Procedure

title: $:/MyProcedure/ListPaging
tag: $:/tags/Global
text:

\procedure list-paging(myfilter,datalimit)
<$vars dataTid=<<qualify"$:/temp/list-paging">>>
    <$set name="dataRest" filter="[title<dataTid>get[text]multiply<datalimit>]">
        <$list filter="[subfilter<myfilter>] +[rest<dataRest>limit<datalimit>]" variable="current" counter="counter">
            <$set name="dataCnt" filter="[<counter>add<dataRest>]">
                <<dataCnt>>: <$button class="tc-btn-invisible tc-tiddlylink">
                        <$action-navigate $to=<<current>> $scroll=yes/>
                    <<current>></$button><br/>
            </$set>
        </$list>
    </$set>
    <$list filter="[subfilter<myfilter>] +[count[]!match[0]]" emptyMessage="0 results">
        <$set name="rangeEnd" filter="[subfilter<myfilter>] +[count[]divide<datalimit>untrunc[]subtract[1]]">
            Go To Page: <$select tiddler=<<dataTid>> field="text" default="0">
                <$list filter="[range[0],<rangeEnd>]" variable="current" counter="counter">
                    <option value=<<current>>><<counter>></option>
                </$list>
            </$select>
        </$set>
    </$list>
</$vars>
\end

then call it anywhere.
The example result is a list with paging every 20 items.

<<list-paging "[!is[system]sort[modified]reverse[]]" 20>>

my Procedure very usefui for large data
if the list more then 10000 items
it will not to show long results in page

and it can be use in custom input, like this:

Title: <$edit-text tiddler="$:/temp/MySearch" field="tempsearchtitle"/>
<$button>Search
    <$action-setfield $tiddler="$:/temp/MySearch" searchtitle={{$:/temp/MySearch!!tempsearchtitle}} />
</$button><br />

<<list-paging "[search:title{$:/temp/MySearch!!searchtitle}] +[!is[system]sort[title]]" 25>>

but there is still a problem
when clicking the “Search” button doesn’t automatically go to page 1.

the “Search” button in outside of Procedure
I cant get the click evevnt to change page where inside of Procedure
I have no idea to solve the problem

maybe somebody can help me to solve it, then I will be grateful.

1 Like

I don’t have any insight into your search problem. I will try to look at it soon. But if you’re interested in other approaches to this pagination problem, see the recent discussion at

1 Like

Sorry for my poor English and inaccurate expression.

The situation I currently encounter is as follows:

testing in https://tiddlywiki.com/

and input the keyword “Operator” get the 14 pages.

1st

  1. go to page 14

  2. change the keyword to “macro”

  3. click the “Search” button

2nd

it will get the empty result

because the title contains “macro” only 5 pages

and the select value still keep “14”

3rd

I used the varible to save list page in Procedure

\procedure list-paging
<$vars dataTid=<<qualify"$:/temp/list-paging">>>

I want to return to the page 1 when I clicking the “Search” button

so I need to fix the Tiddler to this:

<$button>Search
    <$action-setfield $tiddler=<<dataTid>> text="0" />
</$button>

but the “Search” button is outside of Procedure

It can not to get the “dataTid” there

4th

I want to know how to trigger changes within the procedure

hope I have explained the problem which I am having

@ricky you have explained yourself well and I understand the problem.

  • let me also say you have written this code quite well.

The problem is you are using qualify inside the procedure to set dataTid and the value is different if qualify is inside or outside the procedure. You have correctly identified that your button is outside the procedure, and cant see the tiddler named in the variable dataTid.

  • Another way to get a qualified tiddlername is to make your own. Lets create one just for the current tiddler, which is where both the button and procedure are “running”.
  • dataTid={{{ [[$:/temp/list-paging/]addsuffix<currentTiddler> }}}>
  • and in the search button add another action, to reset the page count using the exact same method to get the tiddlername
<$action-setfield $tiddler={{{ [[$:/temp/list-paging/]addsuffix<currentTiddler>] }}} $value="0"/>
  • This fixes the problem.

However consider changing it so;

  • The number of results, and number pages available, is shown before the list. Then you know how big the results are, even before clicking on the pages.
  • See if you can change it so the first page is one, not zero. Its more meaningful so after the first list it reads goto page 2 (not one)
  • You could put the button a inside the list-paging procedure as well as I did below.
  • your could change all your tempaoary tiddlers /fields in tiddlers to one with to use {{{ [[$:/temp/list-paging/]addsuffix<currentTiddler>] }}}

Otherwise great work!

Here is my final result without changing the first page to 1

\procedure list-paging(myfilter,datalimit)
Title: <$edit-text tiddler="$:/temp/MySearch" field="tempsearchtitle"/>
<$button>Search
    <$action-setfield $tiddler="$:/temp/MySearch" searchtitle={{$:/temp/MySearch!!tempsearchtitle}} />
    <$action-setfield $tiddler={{{ [[$:/temp/list-paging/]addsuffix<currentTiddler>] }}} $value="0"/>
</$button><br />
<$vars dataTid={{{ [[$:/temp/list-paging/]addsuffix<currentTiddler>] }}}>
    <$set name="dataRest" filter="[title<dataTid>get[text]multiply<datalimit>]">
        <$list filter="[subfilter<myfilter>] +[rest<dataRest>limit<datalimit>]" variable="current" counter="counter">
            <$set name="dataCnt" filter="[<counter>add<dataRest>]">
                <<dataCnt>>: <$button class="tc-btn-invisible tc-tiddlylink">
                        <$action-navigate $to=<<current>> $scroll=yes/>
                    <<current>></$button><br/>
            </$set>
        </$list>
    </$set>
    <$list filter="[subfilter<myfilter>] +[count[]!match[0]]" emptyMessage="0 results">
        <$set name="rangeEnd" filter="[subfilter<myfilter>] +[count[]divide<datalimit>untrunc[]subtract[1]]">
            Go To Page: <$select tiddler=<<dataTid>> field="text" default="0">
                <$list filter="[range[0],<rangeEnd>]" variable="current" counter="counter">
                    <option value=<<current>>><<counter>></option>
                </$list>
            </$select>
        </$set>
    </$list>
</$vars>
\end

Then in any tiddler,

<<list-paging "[search:title{$:/temp/MySearch!!searchtitle}] +[!is[system]sort[title]]" 25>>

[Post Script] You could also ask the user to enter /select items per page, not only as a prameter.

2 Likes

Let us know if you want more information on this.

Perhaps start a new thread?

1 Like