On Friday, February 28, 2014 10:27:41 AM UTC-8, Joe Shirk wrote:
>
>
> the first problem is that the help texts about 
> http://tiddlywiki.com/static/ListWidget.html or 
> http://tiddlywiki.com/static/TiddlerFilters.html does not give a syntax 
> on how to call the list filter. I assume the method requires an include, 
> such i tried here Work History [rev. #1674697] (it's not possible to get 
> you a link to the revision in either firefox or chrome; the links are 
> broken)
>

TWC is located at http://classic.tiddlywiki.com ... everything at 
http://tiddlywiki.com is for TW5... the documentation you mention is for 
TW5 syntax ONLY.

use case:
> list all tiddlers tagged 'History' in chronological order, that is, fields 
> start_date end_date link-to-tiddler ordered by end_date (reverse).
>

This can be done with ForEachTiddler, which takes javascript fragments as 
parameter "clauses" (where, sortby, write, start, end, script).  The macro 
inserts those code fragments into a 'harness' loop that retrieves all 
tiddlers, applies the "where" clause test to select tiddlers, and then 
sorts and writes output based on that selected list.

However... the syntax for ForEachTiddler can be a bit fussy, because the 
enclosing macro syntax makes use of quotes around the parameter values, so 
quotes *within* the code fragments can get problematic: if you use 
double-quotes around the parameter, you can only use single-quotes within 
the parameter value.

Fortunately, there is another way to write custom "select and output" 
handling... using plain Javascript.

First, install this plugin:
http://www.TiddlyTools.com/#InlineJavascriptPlugin

This plugin extends the TWC parser so that it can recognize 
<script>...</script> blocks within tiddler content, which it passes on to 
the browser's javascript engine for processing.  Within the script, you can 
invoke any TWCore functions you need to select/sort tiddlers and access 
their field values to generate output text, which is then returned at the 
end of the script and rendered ("wikified") by the TWCore.

For your purposes, the following script should do what you want:
-------------
<script>
   var tag="History";
   var srt="-end_date";
   var out="";
   var hdr="|!start|!end|!title|\n";
   var fmt="|%0|%1|[[%2]]|\n";
   var tids=store.sortTiddlers(store.getTaggedTiddlers(tag),srt);
   if (tids.length) out+=hdr;
   for (var i=0; i<tids.length; i++)
      out+=fmt.format([tids[i].start_date,tids[i].end_date,tids[i].title]);
   return out;
</script>
-------------
Notes:
* start by defining some variables (mostly for readability): the tag to 
match, the sort field (the "-" prefix means reverse order), the output 
buffer, a heading for table columns, and the format for output of table rows
* retrieve the tiddlers that match the tag, and sort them.
* if there are any matching tiddlers, output a table heading
* loop through the matched tiddlers and output the start/end dates and 
linked title
* return the buffered output

enjoy,
-e
Eric Shulman
TiddlyTools / ELS Design Studios

YOUR DONATIONS ARE VERY IMPORTANT!
HELP ME TO HELP YOU - MAKE A CONTRIBUTION TO MY "TIP JAR"...
   http://TiddlyTools.github.com/fundraising.html#MakeADonation

Professional TiddlyWiki Consulting Services...
Analysis, Design, and Custom Solutions:
   http://www.TiddlyTools.com/#Contact

-- 
You received this message because you are subscribed to the Google Groups 
"TiddlyWiki" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to tiddlywiki+unsubscr...@googlegroups.com.
To post to this group, send email to tiddlywiki@googlegroups.com.
Visit this group at http://groups.google.com/group/tiddlywiki.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to