> The solution you helped me with does not work when there are two field
> values.

I think you meant to say "when there are two space-separated values in
the single custom field".

> I've tried using a for loop on
> var v=store.getTaggedTiddlers(u.readBracketedList()[0]);
> but have had no joy.

The previous example code assumed that only the first space-separated
value in the field would be used to find tagged tiddlers.  To
accomplish your desired results, what you want to do is to loop
through all space-separated values in the field, and gather the titles
of all tiddlers tagged with one (or more) of those values, listing
each matched tiddler only once, regardless of the number of matching
tags it has.

This can be done with a double-nested for(...) loop.  But the code is
ugly and not very easy to read/understand... and, fortunately, not
needed!

The TW core has a function, store.filterTiddlers(), that can return a
set of tiddlers that match a given *tag filter* definition.  The
core's filter syntax for matching any one of several tag values is
   "[tag[val1]][tag[val2]][tag[val3]][tag[val4]]"

So, instead of using double-nested loops, we can construct the desired
filter text using the above syntax, and then fetch the list of
matching titles with a single call to filterTiddlers(...), like this:

for (var i=0; i<tids.length; i++) {
        var val=store.getValue(tids[i],"field1");
        var filter="[tag["+val.readBracketedList().join("]][tag[")+"]]";
        var list=store.filterTiddlers(filter).map(function(t){return
"[["+t.title+"]]"});
        out.push('|'+tids[i].title+'|'+val+'|'+list.join(" ")+'|');
}

enjoy,
-e

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"TiddlyWiki" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/tiddlywiki?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to