Terminology
A Dynamic Filter is a filter created at run time (render time) and is not hard coded into the WikiText (script).
A Static Filter is a filter known at the scripting time and is hard coded into the WikiText (script).
Example
- This example uses a static filter and lists all tiddlers tagged with
HelloThere
<$list filter="[tag[HelloThere]]">
...
...
- Below example shows a simple dynamic filter. It selects the correct filter based on a user input. For demonstration purpose and simplicity I used a macro here:
\define dynafilter(userinput)
<$set name=mainFilter filter="[<__userinput__>match[1]then<noteFilter>else<journalFilter>]">
<$list filter=<<mainFilter>> ...
...
...
\end
This example gets the user input if it is equal to 1
, then it lists note tiddlers using noteFilter
, in all other cases it lists journal tiddlers using journalFilter
.
Questions
I wish to know what is the best practice here to dynamically set a filter based on some conditions?
References
- @saqimtiaz resources (Q&A, plugins)
- @EricShulman resources (Q&A, plugins)
- Shiraz plugin
- Mehregan edition
- @Charlie_Veniot has also some good examples constructing filters dynamically
- How to insert partial filter expression into larger filter expressions? - Discussion - Talk TW (tiddlywiki.org)
- More direct way to insert “[[” and “]]” in filters - Discussion - Talk TW (tiddlywiki.org)
- [tw5] Just a Filtering Code Pattern - Google Group (Read Only) - Talk TW (tiddlywiki.org)