New macro list-pages: Looking for a simpler solution

214 views
Skip to first unread message

Mohammad Rahmani

unread,
Feb 24, 2021, 7:26:10 AM2/24/21
to tiddl...@googlegroups.com
I have developed a list-pages macros similar to list-links, but it is a little lengthy

\define list-pages(filter, entries-per-page:5, template, stateTid:"pagingTid")
<$vars stateTid=<<qualify xx$/state/$stateTid$>> >
<$vars total-entries={{{ [subfilter<__filter__>count[]] }}}
page-number={{{[<stateTid>get[text]] ~[[1]]}}} >
<$vars low={{{[<page-number>subtract[1]multiply<__entries-per-page__>]}}}  
       high={{{[<page-number>multiply<__entries-per-page__>]}}} >

<!-- create nav buttons --->
<$list filter="[<page-number>compare:number:lt[2]then[yes]else[no]]" variable=state>
<$button disabled=<<state>> >Prev
<$action-listops $tiddler=<<stateTid>> $field=text $subfilter="+[subtract[1]] ~[[1]]"/>
</$button>
</$list>
<$list filter="[<high>compare:number:gteq<total-entries>then[yes]else[no]]" variable=state>
<$button disabled=<<state>>>Next
<$action-listops $tiddler=<<stateTid>> $field=text $subfilter="+[add[1]] ~[[2]]"/>
</$button>
</$list>

Displaying <$text text={{{[<low>add[1]]}}}/> through <<high>> of <<total-entries>> Results

<$list filter="[subfilter<__filter__>first<high>] -[subfilter<__filter__>first<low>]" template=<<__template__>> />

</$vars>
</$vars>
</$vars>
\end



It accepts:
* any Tiddlywiki filter or filter combinations
* it accepts template (so it is very powerful in creating different outputs
* can be used in a tiddler several times (has stateTid)
* number of output per page can be set

This macro can be hacked and used for situations where you have too many outputs. Paging prevents a long output and hence slows down TW performance!

Evaluations
To give a try, download attached JSON and drag and drop into https://tiddlywiki.com/
Look at the Test tiddler
As an example a simple template was created for test purposes.

Question:
What simpler solution do you propose?
What improvement do you suggest? 


Best wishes
Mohammad
list-page-macro-with-example.json

Mohammad Rahmani

unread,
Feb 24, 2021, 7:28:07 AM2/24/21
to tiddl...@googlegroups.com
In the call to qualify the xx$/state is used on purpose to see the stateTid
Remove xx after test!

Best wishes
Mohammad

Eskha

unread,
Feb 24, 2021, 10:11:48 AM2/24/21
to TiddlyWiki
Hello Mohammad,

Thank you for this useful macro.

I was wondering if it was possible to integrate it with Tobias list-search macro (see below) since it would be a very powerful combination?

Best regards,

Eskha


\define list-search(
filter:"[tags[]]",
search:"search:title",
state:"$:/temp/list-search", 
template:"$:/core/ui/ListItemTemplate",
placeholder:"Filter",
limit:100000
)
<div>
<$edit-text
tiddler="$state$"
type="search"
tag="input"
default=""
placeholder="$placeholder$"/>
</div>

<$reveal state="$state$" type="match" text="">
<$list filter="$filter$+[limit[$limit$]]" template="$template$"/>
</$reveal>

<$reveal state="$state$" type="nomatch" text="">
<$list filter="$filter$+[$search${$state$}]+[limit[$limit$]]" template="$template$"/>
</$reveal>
\end

Mohammad Rahmani

unread,
Feb 24, 2021, 11:09:24 AM2/24/21
to tiddl...@googlegroups.com
Hi Eshka,
 There is a similar macro in Shiraz! 
To have a list-search like behavior, you can call list-pages as below

<$macrocall $name=list-pages filter={{some-tiddler}} ...

Then having a edit-text like below
<$edit-text
tiddler="some-tiddler"
type="search"
tag="input"
default=""
....

That's all. 

You may write your own macro to call list-pages as above. something like list-search-pages ;-)


Best wishes
Mohammad


--
You received this message because you are subscribed to the Google Groups "TiddlyWiki" group.
To unsubscribe from this group and stop receiving emails from it, send an email to tiddlywiki+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/tiddlywiki/24fce8f6-f523-4cb4-b54f-9027b04b4c23n%40googlegroups.com.

Mohammad Rahmani

unread,
Feb 24, 2021, 11:24:53 AM2/24/21
to tiddl...@googlegroups.com
Eska,

In tiddlywiki.com give a try for the code below. I assume you have you have already the list-pages working in  tiddlywiki.com

\define list-search-pages()
<$edit-text
tiddler="some-tiddler"
type="search"
tag="input"
default=""/>

><$macrocall $name=list-pages filter={{some-tiddler}} entries-per-page=10  />
\end

Then enter in the edit box something like this: [tag[Definitions]]


Best wishes
Mohammad


On Wed, Feb 24, 2021 at 6:41 PM Eskha <khask...@gmail.com> wrote:
--

History Buff

unread,
Feb 24, 2021, 4:54:22 PM2/24/21
to TiddlyWiki
Mohammad,

Love this macro. I was wondering how I could use this with dynamic tables such that I could say display only 10 rows at a time and page through them.

Thanks,

Damon

Mohammad Rahmani

unread,
Feb 25, 2021, 12:38:52 AM2/25/21
to tiddl...@googlegroups.com


On Thu, Feb 25, 2021 at 1:24 AM History Buff <damon.p...@gmail.com> wrote:
Mohammad,

Hi Damon,

Love this macro. I was wondering how I could use this with dynamic tables such that I could say display only 10 rows at a time and page through them.


Sure, you should be able to hack dynamic tables and add this feature yourself.

I plan to push an update and add this feature to Shiraz (e.g. Dynamic tables)

 
Thanks,

Best wishes
Mohammad

Eskha

unread,
Feb 25, 2021, 2:46:50 AM2/25/21
to TiddlyWiki
Thank you Mohammad for your answer.

I can confirm that it is working on TiddlyWiki.

However it is not exactly the behavior I was expecting.
Indeed when using the list-search macro, the filter option is different from the text input.
You define the filter in the macro-call, for instance "[tag[Definitions]]" (or use default filter "[tags[]]").
Then, the text you write into the text input narrow down the search to the filtered titles matching the text input.
For instance (on Tiddlywiki.com) with the filter option "[tag[Definitions]]" and the text "URI", you would only see two elements in the list: Data URI and URI.
In your use-case, the text input is replacing the filter option.

For other, I add a link to your well explained "demo/list-search-macro" tiddler:

To summarize, what would be my "ideal" behavior would be that an optional "entries-per-page" attribute exists in list-search!

Best regards,

Eskha





Mohammad Rahmani

unread,
Feb 25, 2021, 4:08:55 AM2/25/21
to tiddl...@googlegroups.com
Hi Eskha

I got your point! You want to refine the search result!
I created an issue https://github.com/kookma/TW-Shiraz/issues/16 to look at this and hopefully add the feature to Shiraz!


Best wishes
Mohammad


Eskha

unread,
Feb 26, 2021, 12:02:53 PM2/26/21
to TiddlyWiki
Hello  Mohammad,

Exactly, I want to refine the search result.
(Useful when the filter returns a lot of matches).
 
Thank you for having a look at it.

Best regards,

Eskha

History Buff

unread,
Feb 27, 2021, 4:05:02 PM2/27/21
to TiddlyWiki
Thank you sir, I appreciate it.

One further question concerning dynamic tables. I know how to sort the tables by column. The question I have is this: is there a way to have a secondary sort column sort? For example, I first want to sort by Column A, but then I want everything sorted by Column B. How would that be done?

Thanks again,

Damon

Mohammad Rahmani

unread,
Feb 27, 2021, 10:12:07 PM2/27/21
to tiddl...@googlegroups.com
On Sun, Feb 28, 2021 at 12:35 AM History Buff <damon.p...@gmail.com> wrote:
Thank you sir, I appreciate it.

You are welcome. The new update of dynamic tables in SHiraz will be pushed to github soon! I have implemented the pagination.

One further question concerning dynamic tables. I know how to sort the tables by column. The question I have is this: is there a way to have a secondary sort column sort? For example, I first want to sort by Column A, but then I want everything sorted by Column B. How would that be done?


Unfortunately no! I have added a ticket to see  this possibility in future!
By the you may know dynamic tables uses the philosophy of TiddlyTables from Alan Aldrich: http://tiddlytables.tiddlyspot.com/

I recommend having a look at TiddlyTables as it is a very powerful tool in creating and manipulating dynamic tables.

 

History Buff

unread,
Feb 27, 2021, 11:53:35 PM2/27/21
to TiddlyWiki
Thanks. I'm looking forward to the update and I will check out TiddlyTables again.

Mohammad Rahmani

unread,
Feb 28, 2021, 1:15:54 AM2/28/21
to tiddl...@googlegroups.com
Hi Eskha,
 This is revision 2 of list-pages. It now combines the features of list-search by Tobias Beer and the first release of list-pages.
 I have attached the second release called list-pages-search. 

Simply download attached file and drag and drop into https://tiddlywiki.com/
Open the Test List-Pages-Search and see how it works.


Please let me know if it works as you explained! I will later add this to Yazd/TW-Scripts for future references.


Best wishes
Mohammad


On Wed, Feb 24, 2021 at 6:41 PM Eskha <khask...@gmail.com> wrote:
--
list-pages-search-macro-with-example.json

Mohammad Rahmani

unread,
Feb 28, 2021, 1:22:41 AM2/28/21
to tiddl...@googlegroups.com
Hi Eskha,

Please use this second attached file. The previous one had a small issue in variable definition.


Best wishes
Mohammad

list-pages-search-macro-with-example.json

Eskha

unread,
Mar 1, 2021, 11:55:51 AM3/1/21
to TiddlyWiki
Hello  Mohammad,

It is perfectly what I was expecting!
Thank you very much.

Best regards,

Eskha
Reply all
Reply to author
Forward
0 new messages