Hi, Tobias.
I tried the new version, however, it seems that "if(i>max)break;"
breaks it. When I hid this line, it displayed the titles.
Also, even when I used num=1,max=2, it ignored the date modified.
I also tried:
x=a[i].title;
y=a[i].tags;
out+=tpl.format([x,y]);
but it didn't work.
And what I need is to display the content of parts or slices or
sections, not fields.

w

On Feb 18, 10:03 pm, Tobias Beer <[email protected]> wrote:
> 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.

-- 
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