<$list filter="[tag[npc-container-peru]tag[npc-adversary]]">
<$transclude mode="block"/>
</$list>
I have tiddlers that are tagged with both tags above, but this list does not return them.
<$list filter="[prefilter[]] -[!tag[npc-container-peru]!tag[npc-adversary]]">
<$transclude mode="block"/>
</$list>
This will return them, but it also returns any tiddler that has only one of those tags.
I want the list to return only the tiddlers that have both tags. What am I doing wrong?
I don’t see anything wrong with your first non-functional example, code-wise. I did check the wiki you’d shared previously, though, and the first thing that jumped out to me was that it didn’t have any tiddlers currently tagged with “npc-container-peru”… but you did have a couple tagged with “container-npc-peru”. This variant did seem to work:
<$list filter="[tag[container-npc-peru]tag[npc-adversary]]">
Of course, you may have changed your tagging conventions in the interim! If this doesn’t solve your problem, feel free to share an updated version and I’ll take another look.
I’m so sorry. I am dyslexic and was unable to see that. Simple coder error. Ugh. Thank you <3
Not at all! Sometimes you just need a second pair of eyes to catch a typo. I know I do, and I’m not dyslexic!
I’d started typing up my usual sanity-check strategy; I’ll post it here in case it helps you avoid some hair-tearing in the future!
When I’m trying to debug a filter, I like to test it with a filtered transclusion, which will produce a simple list of links to each result of the filter. In this case, that would look like
{{{ [tag[npc-container-peru]tag[npc-adversary]] }}}
(Alternately, you can paste your filter into the Filter tab of Advanced Search… but if I’m already in edit mode, it’s usually more convenient just to use a filtered transclusion + live preview.)
This can be a good initial check because it lets us isolate the filter itself from any content you may have inside the list widget—which might be malfunctioning for reasons unrelated to the filter, or might just not produce the results you’re expecting.
- For instance, my first hypothesis upon reading your post was that the problem wasn’t with the filter (which looked great, syntactically speaking), but with the list template you were using. I knew that
<$transclude mode=block /> transcludes the content of the text field; if the tiddlers in question didn’t have any text, the list wouldn’t yield any visible results, even if it had returned the correct set of tiddlers.
- However, the filtered transclusion didn’t return any results either—which meant the problem had to be with the filter itself.
Once I’ve determined that I do have a filter problem, I start removing filter steps until I get the results I’d expect—or I start from a single-step filter and re-add subsequent steps until it breaks.
- In this case,
{{{ [tag[npc-container-peru]] }}} didn’t produce any results, which told me that the “npc-container-peru” tag didn’t exist.
- However,
{{{ [tag[npc-adversary]] }}} does work. Since I now have a convenient list of tiddlers with the “npc-adversary” tag, I clicked on one and noticed the tag discrepancy. And just to test it, I added the “npc-container-peru” tag to this tiddler, saved it, and tried your original filter again, and that solved it.
This is great. Thank you for breaking down your debugging thought process! I suck at logic, so this is very helpful! Thank you 