Generating a list based on custom fields.

30 views
Skip to first unread message

Jakob Graulund Jørgensen

unread,
Nov 19, 2009, 11:12:17 AM11/19/09
to TiddlyWiki
Hi

I'm trying to create a couple of alphabetazied lists (ei. a-m, n-t, u-
z) . The lists have to be alpabetazied according to tiddlers' custom
fields, and I want the costum fields to be what is displayed in the
list (ie. not the title as usually).

I cant however quite make it work.

My guess is something like

<<forEachTiddler
where
' store.getValue(tiddler,"fieldone") &&
store.getValue(tiddler,"fieldone").readBracketedList().startsWith
(["A"]) '

write
' " <<tiddler FakeLink with: "+tiddler.title+" >\> \n" '

>>

And then creating a tiddler called [[FakeLink]], containing:
----------
/%
!out
[[$1|$2]]
!end
%/<<tiddler FakeLink##out with:
{{store.getValue('$1','fieldone')}} [[$1]]>>
----------

This only works with

where
' store.getValue(tiddler,"fieldone") &&
store.getValue(tiddler,"fieldone").readBracketedList().contains
(["A"]) '

which result in a less than alphabetized list.

hope the make sense and that somebody can help me

Måns

unread,
Nov 19, 2009, 11:38:15 AM11/19/09
to TiddlyWiki
sortBy 'tiddler.fields["fieldone"]' ??

<<forEachTiddler
where
' store.getValue(tiddler,"fieldone") &&
store.getValue(tiddler,"fieldone").readBracketedList().contains
(["A"]) '
sortBy 'tiddler.fields["fieldone"]'

Måns

On 19 Nov., 17:12, Jakob Graulund Jørgensen <jakobgraul...@gmail.com>
wrote:

Måns

unread,
Nov 19, 2009, 11:43:54 AM11/19/09
to TiddlyWiki
Maybe even: sortBy 'tiddler.fields["fieldone"].toUpperCase()'
Don't know if it's written in the right place... But I know it works
with this:
sortBy 'tiddler.title.toUpperCase()'

Regards Måns Mårtensson

Jakob Graulund Jørgensen

unread,
Nov 19, 2009, 11:53:08 AM11/19/09
to TiddlyWiki
> sortBy 'tiddler.fields["fieldone"]' ??

it is
store.getValue(tiddler,"fieldone").readBracketedList().contains
that is the problem. It doesnt distinguish between for example
"aaaBccc" and "cccBaaa"

Which is why i want to use .startsWith but i cant make that work


Måns

unread,
Nov 19, 2009, 12:36:36 PM11/19/09
to TiddlyWiki
I found this: http://tinyurl.com/yzpw5k7

Maybe it's the where
'tiddler.title.startsWith("Site")'

Which you could change to sth usable
where
'tiddler.fields["fieldone"].startsWith("A")'

???

regards Måns Mårtensson

On 19 Nov., 17:53, Jakob Graulund Jørgensen <jakobgraul...@gmail.com>
wrote:

Jakob Graulund Jørgensen

unread,
Nov 19, 2009, 1:59:45 PM11/19/09
to TiddlyWiki
>  'tiddler.fields["fieldone"].startsWith("A")'

it is a good idea but I simply cant get the .startswith to work. same
problem as my original.

Tobias Beer

unread,
Nov 21, 2009, 3:59:19 PM11/21/09
to TiddlyWiki
How about some good old...

indexOf('A')==0

?

Tobias.

Tobias Beer

unread,
Nov 21, 2009, 4:08:17 PM11/21/09
to TiddlyWiki
Sorry, didn't pay attention.

startsWith is a string function added by FET to the string prototype.
You can't perform on an array, which is what readBracketedList()
returns. So, do you have to do a readBracketedList to begin with?

What about...
store.getValue(tiddler,"fieldone").startsWith(["A"])

Or simply...
store.getValue(tiddler,"fieldone").indexOf("A")==0

Tobias.

Tobias Beer

unread,
Nov 21, 2009, 4:10:56 PM11/21/09
to TiddlyWiki
Also, startsWith seems to take a string as an input parameter, not an
array.

So...
startsWith(["A"])

Should be...
startsWith("A")


Shouldn't it?


Tobias.

Jakob Graulund Jørgensen

unread,
Nov 23, 2009, 10:41:53 AM11/23/09
to TiddlyWiki
>startsWith is a string function added by FET to the string prototype.
>You can't perform on an array, which is what readBracketedList()
>returns. So, do you have to do a readBracketedList to begin with?

Obviously the simpler thing always works perfectly:

<<forEachTiddler
where
' store.getValue(tiddler,"fieldone") && store.getValue
(tiddler,"fieldone").startsWith(["A"]) '

write

' " <<tiddler FakeLink with: [["+tiddler.title+"]] >\> \n" ' >>

Thx you for the help
Reply all
Reply to author
Forward
0 new messages