Use fields as filter argument

593 views
Skip to first unread message

Ivan Aparicio

unread,
Sep 3, 2016, 7:51:46 AM9/3/16
to TiddlyWiki
Hi everybody,

I'm new to TiddlyWiki and I'm trying to use it to create a project-specific to-do list. Please bear with me if this is a pretty simple question, but I think I may need to use a tiddler field (tiddler title) as a filter argument. Let me explain:

Each project is a tiddler with a task list, let's say it's called Project1.

Each task is named with the following convention Project1:Task1.

The Project1 tiddler has the following wikitext, styled after the TaskManagementExample tiddler on tiddlywiki.com:

! Outstanding tasks

<$list filter="[!has[draft.of]tag[task]!tag[done]sort[created]regexp[{{!!title}}]]">

<$checkbox tag="done"> <$link to={{!!title}}><$view field="title"/></$link></$checkbox>

</$list>

! Completed tasks

<$list filter="[!has[draft.of]tag[task]tag[done]sort[created]regexp[{{!!title}}]]">

<$checkbox tag="done"> ~~<$link to={{!!title}}><$view field="title"/></$link>~~</$checkbox>

</$list>

Please note that I've added a regexp filter operator to only find the tasks relevant to Project1. I get this to work when I put the operator regexp[Project1], but I would like this wikitext to work on all of my project tiddlers.

I hope that's clear. Does anybody know why this doesn't work?

Thanks!

Mark S.

unread,
Sep 3, 2016, 10:12:12 AM9/3/16
to TiddlyWiki
I don't know if this is your only problem, but when used in a filter I believe the syntax for transclusion is ...regex{!!title}...

HTH
Mark

Ivan Aparicio

unread,
Sep 3, 2016, 10:23:08 AM9/3/16
to TiddlyWiki
Thanks Mark! That worked

Ivan Aparicio

unread,
Sep 3, 2016, 5:09:19 PM9/3/16
to TiddlyWiki
Do you know if it's possible to concatenate the field (or title) with the colon that follows it? I'm trying to distinguish between project tasks - Project1:Task1 and Project1~Log1. I've been reviewing the docs and it seems that it may be possible to do this with a macro, but I can't get a match with the regex. The macro that I'm using is:

\define projectRegex(regex:{{!!title}}:\w+)
$regex$
\end

I then use regexp[<<projectRegex>>] in the code above, expecting to see a filtering, but both Project1:Task1 and Project1:Log1 are returned.



On Saturday, September 3, 2016 at 3:12:12 PM UTC+1, Mark S. wrote:

Mark S.

unread,
Sep 3, 2016, 6:13:47 PM9/3/16
to TiddlyWiki
Once again, the syntax is different inside a filter. When referencing a variable, use ...regexp<variable>...

However, since you're really just looking for a prefix, maybe use the prefix operator (prefix[]). Here's how I could do what you wanted using the prefix operator and a variable (catcolon) to concatenate the colon:

\define catcolon() $(pfix)$:
<$set name=pfix value={{!!title}}>

<$list filter="[!has[draft.of]tag[task]!tag[done]sort[created]prefix<catcolon>]">


<$checkbox tag="done"> <$link to={{!!title}}><$view field="title"/></$link></$checkbox>

<
/$list>
</
$set>

If you wanted to concatenate a title with a tilde, then you could use instead:

\define cattilde() $(pfix)$~

<$set name=pfix value={{!!title}}>

<$list filter="[!has[draft.of]tag[task]!tag[done]sort[created]prefix<cattilde>]">


<$checkbox tag="done"> <$link to={{!!title}}><$view field="title"/></$link></$checkbox>

<
/$list>
</
$set>

HTH
Mark

PMario

unread,
Sep 3, 2016, 6:29:16 PM9/3/16
to TiddlyWiki
Hi Ivan,

Is there a special reason, why you create your list based on names? IMO it would be much easier to use tags. TW is highliy optimized to create tag based lists. regexp filters are powerful, but can be extremely complicated very fast.

eg: I'd name my projects like this:

 - myProject-one
 - myProject-two

and tag them project. So to see all my projects in a list I just need: <<list-links filter:"[tag[project]]">>

my tasks ma be named:

 - task-1 ... tagged task and myProject-one
 - task-2 ... tagged task and myProject-one

- task-3 ... tagged task and myProject-two

So listing all task is: <<list-links filter:"[tag[task]]">>

Then I'd use the existing table-of-content macro like this: <<toc project>> to give me an overview. See: http://tiddlywiki.com/#Table-of-Contents%20Macros%20(Examples)  This macro can do a lot of crazy things.

<<toc myProject-one>> and so on.

just some thoughts.

have fun!
mario



Ivan Aparicio

unread,
Sep 4, 2016, 5:26:41 PM9/4/16
to TiddlyWiki
Thanks guys, that's really useful stuff! I'll keep experimenting, but I may just take Mario's advice, because it seems that a tagging approach is most in harmony with how TiddlyWiki is built.

Jed Carty

unread,
Sep 14, 2016, 12:17:11 PM9/14/16
to TiddlyWiki
Reply all
Reply to author
Forward
0 new messages