Using custom field values as filter parameters

229 views
Skip to first unread message

Дмитрий Ивашкин

unread,
Apr 22, 2014, 8:16:52 AM4/22/14
to tiddl...@googlegroups.com
Hi, I'm trying to make a filter that shows tiddlers created by a certain date.

So, I have a tiddler that has custom "day" field. Then I have an interface to change it:

<$edit-text field="day" tag="input" type="date"/>

So far, so good. Then I have a list of tiddlers that were created on the selected date:

<$list filter="[sameday[???]!is[system]]">
<$view field="title"/>
</$list>

How do I insert content of "day" field from current tiddler to the search field of the filter above? Is there a way to do that?

FrD

unread,
Apr 22, 2014, 8:37:16 AM4/22/14
to tiddl...@googlegroups.com
Hi,

I have the same problem : using a field value in a filter expression.
So far I use a macro and a variable :

At the beginning of the tiddler :

\define myFilter()
<$list filter="[sameday[$(fieldvalue)$]!is[system]]">
<$view field="title"/>
</$list>
\end

and then use it like that :

<$set name="fieldvalue" value={{!!day}}>
<<myFilter>>
</$set>

FrD

Dmitry Ivashkin

unread,
Apr 22, 2014, 8:57:05 AM4/22/14
to tiddl...@googlegroups.com
Hi, thanks a lot, that actually helps!

The only problem left for now is that <$edit-text field="day" tag="input" type="date"/> makes my 'day' field be in YYYY-MM-DD format, while filter expects it in YYYY0MM0DD.
I'm not sure what is the proper way to convert one to another. Except maybe for just changing config.views.wikified.dateFormat.


--
Best regards,
Dmitry Ivashkin


--
You received this message because you are subscribed to a topic in the Google Groups "TiddlyWiki" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/tiddlywiki/3Mrzau2Ymvg/unsubscribe.
To unsubscribe from this group and all its topics, send an email to tiddlywiki+...@googlegroups.com.
To post to this group, send email to tiddl...@googlegroups.com.
Visit this group at http://groups.google.com/group/tiddlywiki.
For more options, visit https://groups.google.com/d/optout.

FrD

unread,
Apr 22, 2014, 10:27:59 AM4/22/14
to tiddl...@googlegroups.com
Hi,

Perhaps simpler (?) :

\define myFilter(fieldvalue)
<$list filter="[sameday[$fieldvalue$]!is[system]]">
<$view field="title"/>
</$list>
\end

and then use it like that :

<$macrocall $name="myFilter" fieldvalue={{!!!day}}/>

As for your format problem, try a simple javascript macro with String.replace()function.

FrD

Dmitry Ivashkin

unread,
Apr 23, 2014, 5:57:14 AM4/23/14
to tiddl...@googlegroups.com
Maybe should be in a separate thread. As for javascript macro, I made a "dateFormat" macro that properly converts date strings for me, but when I use it in my tiddler as:

<<dateFormat {{!!day}}>>

it gets "{{!!day}}" string literal as a parameter, not the value of field "day". Is there any sort of escaping syntax for that?

--
Best regards,
Dmitry Ivashkin


Danielo Rodríguez

unread,
Apr 23, 2014, 9:16:19 AM4/23/14
to tiddl...@googlegroups.com
Try with the macrocall widget.

FrD

unread,
Apr 23, 2014, 10:21:45 AM4/23/14
to tiddl...@googlegroups.com
Hi,

As Danielo said :

<$macrocall $name="dateFormat" nameOfYourParameter={{!!day}}/>

FrD
Reply all
Reply to author
Forward
0 new messages