<<list filter .... question: select tagged tiddlers and show summary slice from each

214 views
Skip to first unread message

TW-lmiller

unread,
Feb 23, 2011, 11:08:08 AM2/23/11
to tiddl...@googlegroups.com
Hi there. I am new to TW and have recently finally understood the power of tagging and filtering. I am building a dynamic list of tiddlers with the tag "project".

For each [project], I would like to show the summary: slice I have in each. (actually I want to show other slices too, but am starting with summary).

I have the following template for my project tiddlers (the (Name), (Content) and (Tags) items are just to describe the tiddler fields from the New Tiddler dialog when clicking on "New Tiddler":

(Title): name of my project
(Content):
   summary: summary of my project
   next step: next thing to do
   other project date
(Tags) : project plus other tags for specifics.

I have a working filter which will show me all of the items tagged with project:

     <<list filter [tag[project]][sort[-modified]]>>

If I had three project tiddlers (Project1, Project2, Project3) it shows

  * Project1
  * Project2
  * Project3

What I would like is for the list to also show the summary slice:

   * Project1 (summary slice from Project1)
   * Project2 (summary slice from Project2)
   * Project3 (summary slice from Project3)


xIt's also OK if the summaries are on the next line:

   * Project1
   ** (summary slice from Project1)
   * Project2
   ** (summary slice from Project2)
   * Project3
   ** (summary slice from Project3)

Any suggestions? I kind of like the way I have my project tiddlers set up so I would rather not bring in a whole new system like MonkeyGTD, etc.

I know there are probably excellent TiddlyTools which would meet my need (and I use a number of them now) but I am expanding my appreciation for tagging and slicing and would like to get my hands in the guts, so to speak.

Appreciate any help.


Eric Shulman

unread,
Feb 23, 2011, 3:38:52 PM2/23/11
to TiddlyWiki
> I know there are probably excellent TiddlyTools which would meet my need
> (and I use a number of them now) but I am expanding my appreciation for
> tagging and slicing and would like to get my hands in the guts, so to speak.

If you use
http://www.TiddlyTools.com/#InlineJavascriptPlugin
you can embed the following script into your tiddler content:

<script>
var out='';
var fmt='* %0 (%1)\n';
var tag='project';
var slice='summary';
var
tids=store.sortTiddlers(store.getTaggedTiddlers(tag),'modified').reverse();
for (var i=0; i<tids.length; i++) {
var t=tids[i].title;
var s=store.getTiddlerSlice(t,slice);
out += fmt.format([t,s]);
}
return out;
</script>

Note: 'fmt' is the output format for each matched tiddler, and uses %0
and %1 as *substitution markers* for the title and summary text,
respectively. To produce the 2-line alternative format you described,
you could change 'fmt' to:
var fmt='* %0\n**%1\n';
Similarly, to use a table format (for nicer column alignments):
var fmt='|%0|%1|\n';

enjoy,
-e
Eric Shulman
TiddlyTools / ELS Design Studios
----------
Was this answer useful? If so, please help support TiddlyTools:

TiddlyTools direct contributions: (paypal)
http://www.TiddlyTools.com/#Donate
UnaMesa tax-deductible contributions:
http://about.unamesa.org/Participate (paypal)
TiddlyWiki consulting:
http://www.TiddlyTools.com/#ELSDesignStudios
http://www.TiddlyTools.com/#Contact

Måns

unread,
Feb 23, 2011, 2:46:21 PM2/23/11
to TiddlyWiki
Hi TW-Imiller

Install Abego-software's ForeachTiddlerPlugin (http://tiddlywiki.abego-
software.de/#ForEachTiddlerPlugin) write:
<<forEachTiddler where 'tiddler.tags.contains("project")'
write
'"[["+tiddler.title+"]]
\nsummary:"+store.getTiddlerSlice(tiddler.title,"summary")+"\n"'>>

For a more advanced table with sortable columns (needs Saq's
TableSortingPlugin http://tw.lewcid.org/#TableSortingPlugin) and a max
limit "(index < 100)?"... write:

<<forEachTiddler where 'tiddler.tags.contains("project")'
sortBy 'tiddler.title.toUpperCase()'
write
'(index < 100)? "|"+(index+1)+"|[["+tiddler.title
+"]]|"+store.getTiddlerSlice(tiddler.title,"summary")+" |\n" : ""'
begin '"|sortable|k\n"
+"| # |projects|summary|h\n"'
end 'count+" tiddler(s) tagged with project\n"' none '"no tiddlers are
tagged with project \n"'>>

Cheers Måns Mårtensson

Måns

unread,
Feb 24, 2011, 8:58:56 AM2/24/11
to TiddlyWiki
addendum
To get the bulleted indented effect you asked for add * and **
like this:
<<forEachTiddler where 'tiddler.tags.contains("project")'
write
'"*[["+tiddler.title+"]]
\n**summary:"+store.getTiddlerSlice(tiddler.title,"summary")+"\n"'>>

If you really want to "get your hands in the guts" of TiddlyWiki - and
want to learn some javascript, you should ofcourse use Eric's
example :-)

Cheers Måns Mårtensson

On 23 Feb., 20:46, Måns <humam...@gmail.com> wrote:
> Hi TW-Imiller
>
> Install Abego-software's ForeachTiddlerPlugin (http://tiddlywiki.abego-
> software.de/#ForEachTiddlerPlugin) write:
> <<forEachTiddler where 'tiddler.tags.contains("project")'
> write
>  '"[["+tiddler.title+"]]
> \nsummary:"+store.getTiddlerSlice(tiddler.title,"summary")+"\n"'>>
>
> For a more advanced table with sortable columns (needs Saq's
> TableSortingPluginhttp://tw.lewcid.org/#TableSortingPlugin) and a max

TW-lmiller

unread,
Feb 24, 2011, 2:46:25 PM2/24/11
to tiddl...@googlegroups.com
Thanks to everyone for those suggestions. To close this thread: I tried both solutions.. Both worked, but I need to tweak ForEachTiddler a little to get the summary slice.


1. ForEachTiddler plugin (BTW - http://tw.lewcid.org/#TableSortingPlugin directs to what looks like a parked domain.):
  * installed plugin ForeachTiddlerPlugin
  * Added content to new tiddler - got a syntax error (not uncommon when cutting and pasting code from forums) - put the write on one line and it does generate a list, however I am getting undefined for the summary slice.
  **  I have a tiddler called "Test Project" with the content "summary: summary for Test Project".
  **  In the tiddler with the ForeachTiddler plugin, I see:
  *** Test Project
        summary: undefined

2. Javascript inline plugin
   * installed Javascriptinlineplugin
   * added script to a new tiddler by pasting script content (I understand what it would do)
   * Shows the summary from Test Project:
      Test Project (test project summary)

I believe Eric's suggestion is what I am looking for and it's gutsy enough for me, but ForEachTiddler seems very useful to have in my toolbox.

Måns

unread,
Feb 24, 2011, 4:21:21 PM2/24/11
to TiddlyWiki
Hi TW-Imiller

> 1. ForEachTiddler plugin (BTW -http://tw.lewcid.org/#TableSortingPlugin
> directs to what looks like a parked domain.):

Sorry I forgot that lewcid.org doesn't exist any longer. Here's the
updated link: http://tiddlywiki.squize.org/#TableSortingPlugin
>   * installed plugin ForeachTiddlerPlugin
>   * Added content to new tiddler - got a syntax error (not uncommon when
> cutting and pasting code from forums) - put the write on one line and it
> does generate a list, however I am getting undefined for the summary slice.
>   **  I have a tiddler called "Test Project" with the content "summary:
> summary for Test Project".
>   **  In the tiddler with the ForeachTiddler plugin, I see:
>   *** Test Project
>         summary: undefined

I believe it caused by google group's linebreaks...
Here I have a working example: http://klasser.tiddlyspace.com/#ForEachExample
> I believe Eric's suggestion is what I am looking for and it's gutsy enough
> for me, but ForEachTiddler seems very useful to have in my toolbox.

Glad to hear that you like ForeachTiddlerPlugin.It's been my lifesaver
for a number of times, and it's quite easy to customize - unlike many
scripts (unless you understand the inner workings of the javascript
language of course...)

ForeachtiddlerPlugin has its limitations, and there's no doubt that
"real" JS-scripting can handle many more things, if you know what you
are doing :-)

Cheers Måns Mårtensson

TW-lmiller

unread,
Feb 24, 2011, 8:49:48 PM2/24/11
to tiddl...@googlegroups.com
Thanks! That worked great! Now I have two methods to choose from.

My next project is to make active/inactive project lists by some version of

     'tiddler.tags.contains("project")' and ''tiddler.tags.contains("active")'

My epiphany on tagging came after I had spent time organizing tiddler dashboards by putting [[title]] links into static tiddlers. I was looking for a way to sort and found a great article on slices and that led me to <<filter.

That article really opened my eyes about having an evolving network of tagged entries rather than a static linkfarm to little notes.


TW-lmiller

unread,
Feb 25, 2011, 12:26:33 PM2/25/11
to tiddl...@googlegroups.com
Thanks again for the help.

Closing the thread for future searches: by futzing around with the code I have both plugins displaying exactly what I want (for now).


Here's what I wound up with as tiddly markup.


! Project tiddlers content
tagged as project
inside tiddler, 2 lines:
summary: project summary
next: next step in project


!Inline Javascript Plugin Tiddler:
!! Desired output
|!tag|!slice|!nxt|
|Project 1 title|Project 1 summary|Project 1 next step|
|Project 2 title|Project 2 summary|Project 2 next step|
|Project Dashboard|c

!! Script result
<script>
   var out='';
   var fmt='|[[%0]]|%1|%2|\n';

   var tag='project';
   var slice='summary';
   var nxt = 'next';
   var tids=store.sortTiddlers(store.getTaggedTiddlers(tag),'modified').reverse();
   out+= "|!" + tag + "|!" + slice + "|!" + nxt + "|\n";

   for (var i=0; i<tids.length; i++) {
      var t=tids[i].title;
      var s=store.getTiddlerSlice(t,slice);
      var n=store.getTiddlerSlice(t,nxt);
      out += fmt.format([t,s,n]);
   }
   out += "|Project Dashboard|c";
   return out;
</script>


! forEachTiddler - better than simple transclusion with <<tiddler>> because list is built automatically from tags
!! Desired output
Tiddler Name
Tiddler Contents

!! forEachTiddler-show project content

<<forEachTiddler
 where
 'tiddler.tags.contains("project")'
  sortBy
 'tiddler.created'
 descending
 write
 '"!\"\"\""+tiddler.title+"\"\"\"\n<<tiddler [["+tiddler.title+"]]$))\n"'
>>


Måns

unread,
Feb 26, 2011, 5:52:34 AM2/26/11
to TiddlyWiki
Hi TW-Imiller

Thanks for showing your solutions and doing a nice write up, it will
go into my tw-notes!
It's nice to have alternatives..

Cheers Måns Mårtensson

rakugo

unread,
Feb 28, 2011, 2:43:15 PM2/28/11
to TiddlyWiki
In tiddlyspace we have been experimenting with a templating approach
using the list macro which we believe is better as it works on a macro
level and doesn't require any javascript knowledge. Check out
http://newtimeline.tiddlyspace.com#SiteInfo
Jon
> >  '"!\"\"\""+tiddler.title+"\"\"\"\n<<tiddler [["+tiddler.title+"]]$))\n"'in

Måns

unread,
Feb 28, 2011, 4:50:43 PM2/28/11
to TiddlyWiki
Hi Jon

> In tiddlyspace we have been experimenting with a templating approach
> using the list macro which we believe is better as it works on a macro
> level and doesn't require any javascript knowledge. Check outhttp://newtimeline.tiddlyspace.com#SiteInfo

That looks very promising :-)

How would you get the summary slice into the template?
Sth like this - doesn't work - What's the correct syntax for
title::summary?:
<<list filter [tag[project]] template:[[ThisTiddlerTitle##template]]
emptyMessage:"No tiddlers to list">>
/%
!template
*<<view title link>>
**summary: <<tiddler title::summary>>
!end
%/

Cheers Måns Mårtensson

Måns

unread,
Mar 2, 2011, 7:35:34 AM3/2/11
to TiddlyWiki
@Jon?
-Bump-

How would you get the summary slice into the template?
Sth like this - doesn't work - What's the correct syntax for
title::summary?:
<<list filter [tag[project]] template:[[ThisTiddlerTitle##template]]
emptyMessage:"No tiddlers to list">>
/%
!template
*<<view title link>>
**summary: <<tiddler title::summary>>
!end
%/

Cheers Måns Mårtensson

rakugo

unread,
Mar 2, 2011, 2:57:04 PM3/2/11
to TiddlyWiki
Hi maans
Sorry I'm travelling at the moment so not able to check this (can't
view source)!! have you tried <<tiddler ##summary>> or
<<tiddler ::summary>> or <<view ##summary text>>

If this isn't in the core the best candidate in my opinion would be to
extend the view macro.. since it is more powerful and extensible...
Jon

Eric Shulman

unread,
Mar 2, 2011, 3:25:46 PM3/2/11
to TiddlyWiki
> <<tiddler ##summary>> or <<tiddler ::summary>> or <<view ##summary text>>
>
> If this isn't in the core the best candidate in my opinion would be to
> extend the view macro.. since it is more powerful and extensible...

The core's <<view>> macro only supports reference to tiddler *fields*
in the current tiddler object. You cannot use it to display slice or
section values, nor can it be used to show values from other tiddlers.

To format and render data -- fields, slices, and/or sections -- from
any tiddler (not just the current one), you can use:
http://www.TiddlyTools.com/#WikifyPlugin

With regard to the core <<tiddler>> macro, it doesn't support use of
section/slice refererences with an "implied tiddler title". The
tiddler reference must include a fully-qualified tiddler title, even
for references to sections/slices in the current tiddler.

Fortunately,
http://www.TiddlyTools.com/#SectionLinksPlugin
enhances the <<tiddler>> macro parameter handling so that section
references that omit the tiddler title (e.g., <<tiddler ##section>>)
are handled by using story.findContainingTiddler() to get the current
tiddler title.

Note that, at present, the SectionLinksPlugin-enhanced parameter
syntax does not support implied titles for *slice* references (e.g.,
"::section"). However, this is relatively easy to add to the existing
plugin code. I'll post a follow-up when an update is available.

Eric Shulman

unread,
Mar 2, 2011, 3:38:39 PM3/2/11
to TiddlyWiki
>    http://www.TiddlyTools.com/#SectionLinksPlugin
> enhances the <<tiddler>> macro parameter handling so that section
> references that omit the tiddler title (e.g., <<tiddler ##section>>)
> are handled by using story.findContainingTiddler() to get the current
> tiddler title.

Note: SectionLinksPlugin functionality WAS originally implemented as a
CoreTweak, and proposed for core inclusion. Unfortunately, after
extensive (and contentious) discussion in a conference call, it was
'rejected', primarily because it was already implemented in the
CoreTweaks plugin, and thus doesn't *need* to go into the core (Oh,
the irony!).

Once it was clear that this change would not be added to the core, I
created the separate SectionLinksPlugin and moved the original
CoreTweak code there, along with several other 'section link' related
features such as
* tiddler *links* that auto-scroll to sections within tiddler
content:
[[TiddlerName##section]]
* use of HTML anchors to create section link 'targets':
<html><a name="sectionname" /></html>
* a <<sectionTOC>> macro that auto-generates an outline-style
'table of contents' for all sections within a tiddler

enjoy,
-e
Reply all
Reply to author
Forward
0 new messages