Using field value as macro input?

152 views
Skip to first unread message

Patrick RB

unread,
Jun 17, 2021, 7:11:12 PM6/17/21
to TiddlyWiki
It look's like this is a common issue for newbies, but I'm using timelines plugin to display tiddler filtered by tags (in this case "snippet")

<<timeline-vertical filter:"[tag[snippet]sort[date]]" date:"date" 

To aid quick searches and avoid editing the tiddler I have created a text box input to set a field to inject input into tag[.....] and a custom date field

I can create, set and check the search field has the expected text, but cannot get the timelines macro to accept the search field text, though the date field works fine.

can any of you real developers help? Thanks! 


Patrick RB

unread,
Jun 21, 2021, 7:47:05 AM6/21/21
to TiddlyWiki
Matybe I wasn't clear enough....

I can get input into a field ("search") and assign it to a variable eg.

\define thisList()
<$list filter="[tag[$(TestVariable)$]]">
\end
<$set name=TestVariable value={{!!search}}>
TestVariable is <<TestVariable>>
This list is <<thisList>>
<br>
</$set>

<$edit-text field="search" default="" placeholder="enter text to search"
tag="input"/>
<br>

this will list all tiddlers tagged with the value of the field "search"

but I can't work out how to use that search term in another existing macro as a filter such as....

<<timeline-vertical filter:"[tag[search]sort[date]]" date:"date">>

or

<<timeline-vertical filter:"[tag[search] sort[date]]" search:"$(search)$" date:"date">>
 
any ideas please?

clutterstack

unread,
Jun 21, 2021, 11:28:33 AM6/21/21
to TiddlyWiki
Hi Patrick,

Sorry if I'm misinterpreting. You can use a text reference in a filter with curly brackets.

It looks as though you're using Mohammad's timeline macros. I went to https://kookma.github.io/TW-Timelines/ and made a new tiddler to test your example. Adding the following gave me a timeline:

<<timeline-vertical filter:"[tag{!!search}sort[date]]" >>

Hope that helps,
Chris

clutterstack

unread,
Jun 21, 2021, 11:34:25 AM6/21/21
to TiddlyWiki
Or I should specify "you can transclude a text reference using curly brackets" since this can be a bit messy to keep straight.

Patrick RB

unread,
Jun 21, 2021, 8:00:48 PM6/21/21
to TiddlyWiki
That's brilliant, thanks so much. It works, but (weirdly?) not if I have the date sorting, and not if the tiddler is put into the sidebar (the search field field doesn't get filled!) 

<$edit-text field="search" default="" placeholder="enter text to search" 
tag="input"/> 
<br>
search is {{!!search}}
<br>
<<timeline-vertical filter:"[tag{!!searchterm}]" limit:4>>


However, this is nearly there and I'm very grateful  ;-)

clutterstack

unread,
Jun 23, 2021, 4:40:55 PM6/23/21
to TiddlyWiki
Sorry I didn't see this, Patrick. I hope you found a solution -- but that looks like a symptom of the fact that the currentTiddler variable doesn't get set automatically in the sidebar. So you're looking for a searchterm (or search?) field on a tiddler that doesn't exist.

One approach is to set a named state tiddler for your edit-text widget to use (so you're not relying on a currentTiddler), then include that name in the filter ( [tag{statetid!!search}]). Another would be to set the currentTiddler variable using transclusion -- rather than putting your search tiddler straight into the sidebar, put a tiddler that transcludes it in the sidebar. More about how transclusion affects currentTiddler at tiddlywiki.com.

Best,
Chris
Reply all
Reply to author
Forward
0 new messages