tiddler array sorted by field

48 views
Skip to first unread message

Jazz

unread,
Jul 14, 2010, 11:29:50 AM7/14/10
to TiddlyWiki
I have the following

config.macros.bullet.handler = function(place, macroName, params,
wikifier, paramString, tiddler)
{
var levA=params[0];
var ecbt=params[1];

var tids=store.getTaggedTiddlers(levA, ecbt);
...


I call this from a tiddler using its macro name:

<<bullet tagName fieldName>>

I would like tids to be an array of tiddlers sorted by the field name.
I get the array, but not sorted.

Sorry if this has been beaten to death, I just could not find the
answer...

PMario

unread,
Jul 14, 2010, 2:06:46 PM7/14/10
to TiddlyWiki
hi
here you can see, how the functions involved look like:
http://www.tiddlytools.com/insideTW/#TiddlyWiki.prototype.reverseLookup
http://www.tiddlytools.com/insideTW/#TiddlyWiki.prototype.getTaggedTiddlers

> <<bullet tagName fieldName>>
>
> I would like tids to be an array of tiddlers sorted by the field name.
> I get the array, but not sorted.
>
> Sorry if this has been beaten to death, I just could not find the
> answer...
I am not sure, how you want to sort. I guess:

tiddler1 tags["hello", "x"], fields{name: "b"}
tiddler2 tags["hello", "y"], fields{name: "a"}

<<bullet hello name>>

should return
*tiddler2
*tiddler1

right?
-regards mario
Message has been deleted

PMario

unread,
Jul 14, 2010, 3:00:00 PM7/14/10
to TiddlyWiki

Jazz

unread,
Jul 15, 2010, 4:24:31 AM7/15/10
to TiddlyWiki
Is it me?

I tried the same, I expect the order in the display message to be
sorted... It is not.

http://xmobile.labs.osmosoft.com/recipes/default/tiddlers.wiki#[[Test%20Order]]%20TestOrderMacro

@PMario, sorry, I cannot see your example (could be a firewall/proxy
issue, I am not sure...).

Jazz

unread,
Jul 15, 2010, 5:38:43 AM7/15/10
to TiddlyWiki
Before I forget, is there a way to adapt the sort to numerical values.

Cheers

PMario

unread,
Jul 15, 2010, 10:55:47 AM7/15/10
to TiddlyWiki
uups,
sry Jazz. The test was too short :)
reverse lookup only looks for the default fields. title, modified,
modifier ... not for custom fields. My match was an accident.

>Before I forget, is there a way to adapt the sort to numerical values.
1) is your number a real number like: 000123456
2) or does it have delimiters like: 0012.34.56

Some time ago, I made a list macro extension NoCaseListPlugin [1]. At
the very end of the code is the sort algorithm.

I used a[sortField].toLowerCase() to get a case insensitive sorting.
May be something like a.fields[sortField].parseInt('1234') does the
trick.
===
some more pointers:
http://www.tiddlytools.com/insideTW/#config.macros.view.handler
<<view fieldName>> can access a custom field
http://www.tiddlytools.com/insideTW/#TiddlyWiki.prototype.getValue
gets the field value.

hope this helps
have fun!
http://hoster.peermore.com/recipes/ListPlugins/tiddlers.wiki#NoCaseListPlugin

Ken Girard

unread,
Jul 15, 2010, 3:19:38 PM7/15/10
to TiddlyWiki
Using ForEachTiddler, TableSortingPlugin and custom fields you can
create most anything.
http://no-sin.com/wiki/WorkTracker.html#%5B%5BNeed%20TM%5D%5D

for example.

<<forEachTiddler
where
'tiddler.tags.contains("needTM")'
sortBy
'store.getValue(tiddler,"traindate")'
write
'"|"+store.getValue(tiddler,"traindate")+" |[["+ tiddler.title+"]]
|"+store.getValue(tiddler,"programcode")
+"|"+store.getValue(tiddler,"agreepackdate")
+"|"+store.getValue(tiddler,"trainmaterialdate")
+"|"+store.getValue(tiddler,"participantmaterialdate")+"|\n"'
begin '"|sortable|k\n|Date|Request|Code|Agree|TM|PM|h\n"'
end '"!"+count+" sets of Trainer Materials needed to be sent\n"'
none '"!No Trainer Materials needed to be sent\n"'
>>

Figure it might give you some ideas.

Ken Girard

On Jul 15, 9:55 am, PMario <pmari...@gmail.com> wrote:
> uups,
> sry Jazz. The test was too short :)
> reverse lookup only looks for the default fields. title, modified,
> modifier ... not for custom fields. My match was an accident.
>
> >Before I forget, is there a way to adapt the sort to numerical values.
>
> 1) is your number a real number like: 000123456
> 2) or does it have delimiters like: 0012.34.56
>
> Some time ago, I made a list macro extension NoCaseListPlugin [1]. At
> the very end of the code is the sort algorithm.
>
> I used a[sortField].toLowerCase() to get a case insensitive sorting.
> May be something like  a.fields[sortField].parseInt('1234') does the
> trick.
> ===
> some more pointers:http://www.tiddlytools.com/insideTW/#config.macros.view.handler
> <<view fieldName>> can access a custom fieldhttp://www.tiddlytools.com/insideTW/#TiddlyWiki.prototype.getValue
> gets the field value.
>
> hope this helps
> have fun!http://hoster.peermore.com/recipes/ListPlugins/tiddlers.wiki#NoCaseLi...
>
> On Jul 15, 10:24 am, Jazz <gery.duca...@gmail.com> wrote:
>
>
>
> > Is it me?
>
> > I tried the same, I expect the order in the display message to be
> > sorted... It is not.
>
> >http://xmobile.labs.osmosoft.com/recipes/default/tiddlers.wiki#[[Test%20Order]]%20TestOrderMacro
>
> > @PMario, sorry, I cannot see your example (could be a firewall/proxy
> > issue, I am not sure...).- Hide quoted text -
>
> - Show quoted text -

PMario

unread,
Jul 17, 2010, 3:15:41 PM7/17/10
to TiddlyWiki
Hi,

On Jul 14, 5:29 pm, Jazz <gery.duca...@gmail.com> wrote:
> I have the following
>
> config.macros.bullet.handler = function(place, macroName, params,
> wikifier, paramString, tiddler)
> {
>     var levA=params[0];
>     var ecbt=params[1];
>
>     var tids=store.getTaggedTiddlers(levA, ecbt);

tids = store.sortTiddlers(tids, ecbt);


found at: http://svn.tiddlywiki.org/Trunk/core/js/TiddlyWiki.js
-m

Reply all
Reply to author
Forward
0 new messages