I have used ForEachTiddler and PartTiddler and have found them to work
well.  I am trying to combine them to automatically create a table of
contents for my address book.  I freely admit that I am not a
javascript programmer, but here is what I tried to do:

Iterate through a list of address book tiddlers sorted by last name.
If last initial changes then
- write </part> for previous initial if needed
- write <part ... hidden> line for new initial
- add tab macro arguments for this new initial to a string buffer.
Write a pretty link for current address book tiddler

After the last tiddler
- Write final </part>
- Write tabs macro

The tabs are displayed with the correct initials, but each tab is
blank.

If I remove the << from the tabs maco, All lines are correctly
formatted, but TW thinks the tiddlers for the tabs the generated
parts) don't exist.  The formatting of the parts appears to be
correct.

Here is the FET call.  Does anyone have suggestions??

Thanks,
Don

<<forEachTiddler
       where 'tiddler.tags.containsAny(["AddressBook"])'
       sortBy 'displayName(tiddler)'
       script ' function getInitial(tiddler)
                   { var m = displayName(tiddler);
                     return m.substr(0,1);
                   }
                   function displayName(tiddler)
                   { var m = DataTiddler.getData(tiddler, "last.name",
"") + ", " + DataTiddler.getData(tiddler, "first.name", "");
                     if (m == ", ")
                     {
                        m = DataTiddler.getData(tiddler, "company",
"");
                     }
                     return m;
                   }
                   function fixTitle(tiddler)
                  {
                     return tiddler.title;
                  }
                   function hdrFtr(tiddler)
                   { var m = "";
                     if (context.lastinit !== getInitial(tiddler))
                    {
                        if (context.lastinit != null)
                       {
                           m = m + "</part>\n";
                        }
                       context.lastinit = getInitial(tiddler);
                       m = m + "<part " + fixTitle(tiddler) + " hidden>
\n";
                       context.tablist = ((context.tablist == null) ?
"" : context.tablist) + "\"" + getInitial(tiddler) + " \" \"" +
getInitial(tiddler) + "\" [[NewAddressBook/" + fixTitle(tiddler) + "]]
\n";
                     }
                     return m;
                   }
'
       write 'hdrFtr(tiddler) + "*[[" + displayName(tiddler) + "|" +
tiddler.title + "]]\n"'
       end '"</part>\n<<tabs txtAddr\n" + context.tablist + ">" + ">
\n"'
>>
--~--~---------~--~----~------------~-------~--~----~
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