I’m a new TiddlyWiki-user and I like it very much.
I even managed to format the output of the list-widget as a table.
This works pretty well, but is there a way to hide the table header when there are no entries?
Here’s the macro-call: <<Items "[tag[item]field:location<currentTiddler>]">>
Maybe there is a way to call the macro only when the filter returns some hits (checking it with count[]), but I’m afraid that with my current (filter-)knowledge doesn’t allow me to do this.
Any help would be very appreciated, thank you.
I’m using TiddlyWiki 5.2.5 with Mozilla Firefox browser 112.0
The first line invokes the desired filter and captures the resultant item list in a variable named “items”
The second line tests the items list to see if it had any contents. If it doesn’t, the remainder of the macro is skipped
The replaced line iterates over all the items found to display the table rows.
Note that there is no need for closing </$list></$set> at the end of the macro. This is because any “unterminated” widgets are automatically closed when the end of the macro is encountered.
You should probably use: <$list filter=<<__filter__>> > here. There is a bit of an advantage internally.
You can either use the reveal-widget or the list-widget to “render” optional content. The disadvantage of the reveal-widget is, that it always creates at least 1 HTML DOM element.
So the way to go, if you don’t want to have any output is with the list-widget like so:
Since calculating complex filters can take much time I did calculate the filter only once, with <$set name="items" filter=<<__filter__>> > … early in the macro.
Then reusing it with filter="[enlist<item>]", which is fast, since it only needs to get the info from the “items-variable”. … I can use this mechanism 2 times.
1st for the “display nothing if empty” logic: <$list filter="[<items>!match[]]" variable="ignore">
See the variable="ignore" … We do not need that variable … the list-widget is used like an “if statement”
otherwise it would use currentTiddler
2nd for the “real filter” … <$list filter="[enlist<items>]" >
I’m afraid that I wouldn’t be an expert soon, I think this could take a BIT longer
Although I’m into programming, too, TiddlyWiki is “another class” and I think that most of the times I’m thinking to complicated about solutions in TiddlyWiki.
What I have learned today is:
Don’t torture, ask a question and save time. this problem has kept me busy the whole weekend.
Filters are much more important than I thought at the first sight
TW has a great user community
My first contact with Tiddlywiki was at the end of January and now I’m wondering how I didn’t found it earlier?
This is a masteriece of software and flexibility and each day I find new possibilities. Easy to learn, but hard to master. I’m simply overwhelmed.
Have a nice day!
Best,
Roland
P.S.: Thank you for your expert tips for “calculating complex filters”
Thank you for the hint, Mohammad.
I have actually installed this on another wiki and it is a great plugin.
But in this wiki (where I wanted to hide the table headers) I tried to solve this without any external help (plugins), i.e. only with the on-board means of the Tiddlywiki.
(and I failed )
But thanks to the help of Eric and Mario, the solution was easy again.