Help on a filter argument, please

79 views
Skip to first unread message

CPorter9

unread,
Aug 20, 2016, 11:29:30 AM8/20/16
to tiddl...@googlegroups.com
(TW5)

I want to transclude a tiddler into a new journal tiddler, and I want the transcluded tiddler to change depending on what day the journal tiddler was created on.

All the tiddlers that I want transcluded are already created, they just need to show up in the new journal tiddler depending on the day the journal tiddler was created. They have a tag for a day (Monday, Tuesday, etc.).

I think this means I first need to find out what day it is when the new journal tiddler is created, then find the tiddler that has the tag for that day, then transclude it into the new journal entry.

(which also means I need to modify the new journal template to include this filter operation, but that's another hurdle to jump.)

I cannot find enough examples of using filters in this way to figure out how to do this.

Mark S.

unread,
Aug 20, 2016, 2:25:07 PM8/20/16
to TiddlyWiki
I think you need a specialty filter or javascript macro. Attached is my quick attempt that you can play with. ABSOLUTELY make sure you have a backup!! Then drag and drop the attached file into your TW, making sure the green import bar shows up, and then selecting "import" for the "Date Test" and javascript macro. There's also a tiddler tagged with "Saturday" to demonstrate that it works today (but it may already be Sunday in other parts of the world). After importing, save and RELOAD to make the javascript macro active.

The code I used to test the javascript macro ("dow" is for Day Of Week) is as follows:

<$set name=field value="created" >
<$list filter="[all[tiddlers]tag
<dow>]">
<$transclude/>
</$list>
</$set>


 Note that the variable "field" needs to be set to the date field you want to track -- "created" in this case.  The reason I pass the value this way is because, for reasons I'm never able to understand, passing the value as a parameter results in a return value that is not seen by other objects, such as filters.

Anyway, as they say, "It worked once."

Good luck!
Mark
day-of-week-kit.json

CPorter9

unread,
Aug 20, 2016, 7:03:56 PM8/20/16
to TiddlyWiki
Thanks, I will try this tonight.

Mat

unread,
Aug 20, 2016, 7:32:19 PM8/20/16
to tiddl...@googlegroups.com
Unless I misunderstand your case, I think it is solvable with wikitext.

I made this. Never mind the... irrelevant stuff.

<:-)

Matabele

unread,
Aug 21, 2016, 1:07:15 AM8/21/16
to TiddlyWiki
Hi

The now macro may be used to get the day-of-the week for today:
<<now DDD>>

This code should, therefore, transclude the text of all tiddlers tagged with todays day-of-the-week:

<$set name=dow value=<<now DDD>>>

<$list filter="[all[tiddlers]tag
<dow>]">

<$transclude/>
</$list>
</$set>

The transclusion will, however, be dynamic -- therefore, a journal entry made today, will tomorrow transclude the content of tiddlers tagged with tomorrow. To create a static journal entry, the tiddler for today's day-of-the-week, must be copied into the new journal entry rather than transcluded i.e. create a template for each day-of-the-week and use this template to create the appropriate new journal.

regards
Reply all
Reply to author
Forward
0 new messages