List of tiddlers and their associated fields

Hi,

How can I show a series of tiddlers as a list of their titles ordered by their created date to also display their associated fields, ideally to only show the fields which begin/contain ‘fieldname’

Eg.

Title A
fieldname 1
fieldname 2

Title B
fieldname 1

Title C
fieldname 1
fieldname 2
fieldname 3

Thanks
Jon

Do you have some way these tags are grouped, such as with tags?

If so, something like

<$list filter="[tag[HelloThere]sort[created]]">

!! <$link/>

# <$text text={{{ [<currentTiddler>fields[]regexp[fieldname*]] -created -text -tags -title -modified }}}/>

</$list>

Edit: Ah, yes that was because I had used the list widget, I have changed it to use the text macro, however I am still trying to work out the correct regular expression for selecting the correct fields, since I imagine you want fields that are both prefixed with fieldname and suffixed with fieldname correct?

Hi, thanks for this.

Yes, there are all tagged.

I tried your solution and it’s nearly there. The fields are shown as under the tiddler title but they are shown as links (and clicking them goes to ‘missing tiddler’)…?

Ok! sorry bout that, here’s the finished result!

<$list filter="[!has[draft.of]tag[HelloThere]sort[created]]">

!! <$link/>

<ol><$list filter="[<currentTiddler>fields[]prefix[fieldname]] [<currentTiddler>fields[]suffix[fieldname]]">

<li><$text text=<<currentTiddler>> > </$text></li>

</$list></ol>
</$list>

This will list all the fields starting with or ending with fieldname in an ordered list, with a link for the tiddler title for quick navigation.

Thanks, just playing around with version 2.

I think I’ve sorted the fieldname part with the first line now being:

<$list filter="[tag[progress]!sort[created]]+[has:field[time-line]]">

so tiddlers can have the fields ‘time-line’ and in addition, also ‘time-line1’, ‘time-line2’ etc.

Ah, sorry, I should have said that I need to see the contents of the fields in the list rather than a list of the fields. Does that make sense?

Oh, yep that does change things a little bit, I’ll work on that and post it here when I got it

Great - sorry about that!

Alrighty!

I think this will be what you’re looking for, took a little tinkering because, if I’m being honest- I sort of forgot you could give variable names to list filters, but anyways, give this a try!

<$list filter="[tag[HelloThere]sort[created]]">

!! <$link><<currentTiddler>></$link>

<ol><$list filter="[tag[HelloThere]fields[]prefix[fieldname]sort[created]] [tag[HelloThere]fields[]suffix[fieldname]sort[created]]" variable=currentField>

   <li><$list filter="[all[current]get<currentField>]">

      <$text text=<<currentTiddler>> > </$text>

   </$list></li>
</$list></ol>

With a tiny modification, you could also have the field next to the field value too, but I just left it as an ordered list just to keep it looking neat.

Just for the sake of anyone attracted by this thread’s title, I’ll put in a plug for Shiraz dynamic tables, and the possibility of doing something like the following (code below):

Display an expandable table with a row for each tiddler that meets a filter condition, and for each such tiddler, display a column for EACH of its fields that meet a filter condition — field name at column-head, field contents in corresponding cell.

Try the following at Shiraz 2.9.0 — create stylish contents in Tiddlywiki
(adding the $:/tags/ViewTemplate tag):

<$set name="myFilter" value={{!!title}}>

<<table-dynamic filter:"[all[tiddlers]tag<myFilter>sort[created]]" caption:"all <$text text={{{[all[tiddlers]tag<myFilter>count[]]}}}/> items tagging: <<tag>>" fields:"[[tbl-expand]] [tag<myFilter>fields[]] -creator -modified -created -modifier -tags -text" emptyMessage:" " sort: "created" sortOp:"nsort" stateTiddler:{{{ [<myFilter>addprefix[$:/state]] }}} sort:page class:"w-100 thead-dark">>

</$set>

Then check out the tiddler for any tag, and see a dynamic table of whatever’s under that tag, with columns for whatever its fields are, minus some of the dull ones, though you could re-include those.

(It would of course be easy to show only those fields that start a certain way, or where the fields themselves are tiddlers with a certain tag, etc.)

1 Like

Hi Justin,

You’re going to regret answering this!

Sorry, can’t get that to work - just gives a list of titles with no field info/reference underneath. Perhaps there’s a tweak or two to make which I’m not expert enough to see.

Hang on. My fault - it works. I’ll just double check

Yep, that’s great Justin.

Many thanks
Jon

Hah! I never regret helping others!

I’m happy this works for you, it was a nice challenge for me to test my know-how :grin:

1 Like

And a variant (worked out before recent reply by @Justin_H) that does not rely on dynamic tables, which works at tiddlywiki.com to illustrate principle. (Using named variables at each level can help keep the code easy to troubleshoot.)

<$list filter="[tag[HelloThere]]" variable="maintid">
<$link to=<<maintid>>/><br>
<$list filter="[<currentTiddler>fields[]prefix[t]] -text" variable="fieldname">
<li><<fieldname>>: {{{ [<maintid>get<fieldname>] }}}</li>
</$list>
</$list>
1 Like

Or with slightly different styling:

<$list filter="[tag[HelloThere]]" variable="maintid">
<$link to=<<maintid>>/><br>
<ul style="list-style: none">
<$list filter="[<currentTiddler>fields[]prefix[t]] -text" variable="fieldname">
<li>''<<fieldname>>'': <$text text ={{{ [<maintid>get<fieldname>] }}}/></li>
</$list>
</ul>
</$list>

Just for fun and because @Scott_Sauyet showed a variant, I thought I would show a variant form using functions.

\function tagged.list(tag) [tag<tag>]
\function t.fields() [fields[]prefix[t]] -[[text]] -[[title]]
\function fieldname-title() [<fieldname>sentencecase[]addsuffix[: ]]
\function fieldname-value() [all[current]get<fieldname>]

<$list filter="[tagged.list[HelloThere]]">
<$link/>
<ul>
<$list filter="[<currentTiddler>t.fields[]]" variable=fieldname>
<li><<fieldname-title>> <<fieldname-value>></li>
</$list>
</ul>
</$list>
  • At first it may not look much better, although I like it.
    • Notice no “messy” text widgets to stop results looking like links.
  • However each of these functions become usable in multiple lists.

I think making a new filter for [tag[HelloThere]] is a bit of over-engineering and even increases complexity instead of simplifying things. It will also make the code harder to maintain.

It was only an illustration, that filter could be extended To select based additional critera.

eg \function tagged.list(tag) [tag<tag>has[title]]

I like it! One minor caveat. For similar reasons to what you said in Struggling with Procedures,

can I suggest you leave the bold wikitext out of this field, then you get to choose it when you display it, not when you set it.

I think the addition of the colon addsuffix[: ] belongs in the formatting, not in the general-purpose function. So:

...
\function fieldname-title() [<fieldname>sentencecase[]]
<!--                                                  ^---- remove addprefix     -->
...
<li><<fieldname-title>>: <<fieldname-value>></li>
<!--                   ^---- here, not in function                               -->
...

On another topic, I know you’ve been playing with functions a lot. One thing that I know is common in TiddlyWiki that bothers me is nonlocality. It’s demonstrated above by the fact that the calls to fieldname-title and fieldname-value do not pass the field “fieldname”. Instead they reach out to the environment they’re running in to pick up these variables. This would be fine in a nested-function situation, but it bothers me when that doesn’t happen.

Whether this bothers others or not, it’s something I’d like to avoid in my own work. But is there an easy way to pass variables as parameters to the function calls? What I would like is something like this:

\function tagged.list(tag) [tag<tag>]
\function t.fields() [fields[]prefix[t]] -[[text]] -[[title]]
\function fieldname-title(fld) [<fld>sentencecase[]]
\function fieldname-value(fld) [all[current]get<fld>]

<$list filter="[tagged.list[HelloThere]]">
<$link/>
<ul>
<$list filter="[<currentTiddler>t.fields[]]" variable=fieldname>
<li><<fieldname-title <<fieldname>> >>: <<fieldname-value <<fieldname>> >></li>
</$list>
</ul>
</$list>

Put that fails syntactically. Is there a simple way to do this?