Hi again, whatever...
Well, you're right, I overlooked those 50... but that's no biggie :-)
<script>
var a=[],i=0,num=10,max=50,n=0,out='',t,tags,x,
tpl="*[[%0]]\n",
tids=store.getTiddlers("modified","excludeLists");
for (t in tids) {
i++;
tags=tids[t].tags;
if (tags&&tags.contains('$1'))a.pushUnique(tids[t],true);
if(i>max)break;
}
while(n<num&&a.length>0){
n++;
i=Math.floor(Math.random()*a.length);
x=a[i].title;
out+=tpl.format([x]);
a.splice(i,1);
}
return out;
</script>
Btw, in case you thought otherwise ...it did retrieve 10 random ones.
I have also added a variable called tpl which lets you specify your
output format. Of course that wont allow you to output anything other
than the tiddlers title. However, if you want to get anything else,
you would have to take the article tiddler referenced via a[i] and
assign the data you want from it to the variable x, for example. If
you need more than one piece of information, add another variable,
maybe y and assign the desired value to it. Then add it to the
tpl.format([]) instruction like this:
//get the title
x=a[i].title;
//get the tags
y=a[i].tags;
//output both
out+=tpl.format([x,y]);
...and so, unless undefined, you also display the tiddlers tags as a
comma separated list. For that, you would also want to change the
template variable "tpl" to output two pieces of information, maybe...
tpl="*[[%0]] (tags: %1)\n"
...whereas %0 would be replaced with the tiddlers title and %1 with
its tags.
As for your question Mans. You would have to change the script as
well. Maybe define the template variable like so...
tpl="*[[%0]] -> fieldX: %1\n"
...and then get the field value from the tiddler object and format
your template accordingly...
//get the title
x=a[i].title;
//get the field value for tiddler a[i]
var f=store.getValue(a[i], "fieldx");
//output both
out+=tpl.format([x,y]);
Cheers, Tobias.