Discussion:
[tw] [TW5] Easy way to display all values in a data tiddler? Macro to create a table based on a list of data tiddlers?
(too old to reply)
Matthew Petty
2016-03-27 11:30:49 UTC
Permalink
I am exploring the use of data dictionary tiddlers, and they seem to be
very useful as a way of having data stored in the text of a tiddler, rather
than in a field or tag.

Here's my thought process -

- I work on multiple projects in my company, each with a job number, WBS
code etc. I have a tiddler with a list of these codes.
- I turned it into a table in the tiddler, before realising it would be
better to have each project code in a separate tiddler.
- First I had each tiddler contain the syntax for a table row: "| A | B
| C |". But this didn't work when I used a list to return them.
- I could have put the HTML tags in, but then I remembered data tiddlers.
- OK, now I have a data tiddler for each project, with the following
values:

jn_company:[[THIS]]
jn_project:[[THAT]]
jn_number:648021
jn_WBS:10003
jn_cc:0089
jn_ct:07
jn_task:000
jn_fnct:00

- By the way, it's nice that a value can be a wiki link.
- So now I can do a list of all the data tiddlers called "Job Number:
xxx", using the following syntax:


<$list filter="[prefix[Job Number:]]">

*{{##jn_company}}
*{{##jn_project}}
*{{##jn_number}}
*{{##jn_WBS}}
*{{##jn_cc}}
*{{##jn_ct}}
*{{##jn_task}}
*{{##jn_fnct}}
</$list>

- But typing out all the text references got a bit tedious.
- So the question is, is there a way to go through all the text
references in order and return their values? Then I could do a macro which
would return a row of a table, without having to specify the text
references.


Sorry for the long post, but I wanted to give some background. Feel free to
point out errors in the above.


Thanks,

Matthew
--
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+***@googlegroups.com.
To post to this group, send email to ***@googlegroups.com.
Visit this group at https://groups.google.com/group/tiddlywiki.
To view this discussion on the web visit https://groups.google.com/d/msgid/tiddlywiki/efd7dd28-06f7-4499-9ff0-61c837dbba67%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Hegart Dmishiv
2016-03-27 15:59:32 UTC
Permalink
Hi Matthew,

It's interesting you should mention this now, as I'm just about to start
using data tiddlers in a quite different way. Maybe it might have some
application for you. Maybe you (or someone else here) will point out a flaw
in my idea that will cause me to have to rethink my solution. Either way,
it's serendipitous.

I'm intending to create a data:value1, value2, ... value*x* structure
within a dictionary tiddler, rather than sticking to the expected data:value
pair. I'll then use a custom macro to extract just the particular value
from the string that is returned from the properly formed data:value pair.

For example, if I have the following data in my *foobar* tiddler :

foo: red,square,37
bar: blue,circle,12
baz: green,triangle,29

...I should be able to do a normal request of *{{foobar##baz}}* which will
return the string "green,triangle,29". I can then chop that string up in a
macro, using text manipulation tools to find the first, second, and third
element, using a macrocall something like...

<$macrocall $name="decombobulate" foobarstring=*{{foobar##baz}}*
returnvalue="2" />

At least, that's the theory of it. I haven't tried it out for real yet. I'm
intending to do this for the TiddlyCRM
<https://groups.google.com/forum/#!searchin/tiddlywiki/CRM/tiddlywiki/9PSw_3OsyyE/qsq9prjaHgAJ>
project I'm working on for the *{{DesignWrite}}*
<https://dl.dropboxusercontent.com/s/tk91wqty552z6z1/designwrite.html>
course semester project
<https://dl.dropboxusercontent.com/s/tk91wqty552z6z1/designwrite.html?dl=0#SemesterProject>.
I don't know if that will be useful for you as well, Matthew, but I'll put
it out there anyway. All feedback gratefully accepted.

Hegart.
Post by Matthew Petty
I am exploring the use of data dictionary tiddlers, and they seem to be
very useful as a way of having data stored in the text of a tiddler, rather
than in a field or tag.
Here's my thought process -
- I work on multiple projects in my company, each with a job number,
WBS code etc. I have a tiddler with a list of these codes.
- I turned it into a table in the tiddler, before realising it would
be better to have each project code in a separate tiddler.
- First I had each tiddler contain the syntax for a table row: "| A |
B | C |". But this didn't work when I used a list to return them.
- I could have put the HTML tags in, but then I remembered data tiddlers.
- OK, now I have a data tiddler for each project, with the following
jn_company:[[THIS]]
jn_project:[[THAT]]
jn_number:648021
jn_WBS:10003
jn_cc:0089
jn_ct:07
jn_task:000
jn_fnct:00
- By the way, it's nice that a value can be a wiki link.
<$list filter="[prefix[Job Number:]]">
*{{##jn_company}}
*{{##jn_project}}
*{{##jn_number}}
*{{##jn_WBS}}
*{{##jn_cc}}
*{{##jn_ct}}
*{{##jn_task}}
*{{##jn_fnct}}
</$list>
- But typing out all the text references got a bit tedious.
- So the question is, is there a way to go through all the text
references in order and return their values? Then I could do a macro which
would return a row of a table, without having to specify the text
references.
Sorry for the long post, but I wanted to give some background. Feel free
to point out errors in the above.
Thanks,
Matthew
--
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+***@googlegroups.com.
To post to this group, send email to ***@googlegroups.com.
Visit this group at https://groups.google.com/group/tiddlywiki.
To view this discussion on the web visit https://groups.google.com/d/msgid/tiddlywiki/074193fc-580c-47a6-b18d-4fa9699ff643%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Eric Shulman
2016-03-27 19:12:30 UTC
Permalink
Post by Matthew Petty
I am exploring the use of data dictionary tiddlers, and they seem to be
very useful as a way of having data stored in the text of a tiddler, rather
than in a field or tag.
- So the question is, is there a way to go through all the text
references in order and return their values? Then I could do a macro which
would return a row of a table, without having to specify the text
references.
You can use the indexes[] filter to get the names of the items in a data
tiddler:
http://tiddlywiki.com/#indexes%20Operator

Something like this:

<ul>
<$list filter="[prefix[Job Number:]]">
<$list filter="[<currentTiddler>indexes[]]" variable="thisIndex">
<li><$view index=<<thisIndex>>/></li>
</$list>
</$list>
</ul>


Note the use of variable="thisIndex"... this allows the inner $list to loop
through the items without changing the value of "currentTiddler" that was
set by the outer $list.


enjoy,
-e
Eric Shulman
TiddlyTools / ELS Design Studios
InsideTiddlyWiki: The Missing Manuals
--
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+***@googlegroups.com.
To post to this group, send email to ***@googlegroups.com.
Visit this group at https://groups.google.com/group/tiddlywiki.
To view this discussion on the web visit https://groups.google.com/d/msgid/tiddlywiki/203c8976-4678-4831-a4fc-13d38d9735c7%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Matthew Petty
2016-03-28 10:17:51 UTC
Permalink
Eric,
That's great, thank you. Now I can have:
<table>
<$list filter="[prefix[Job Number:]]">
<tr><td>{{!!title}}</td><$list filter="[<currentTiddler>indexes[]]"
variable="thisIndex">
<td><$view index=<<thisIndex>>/></td>
</$list></tr></$list>
</table>
Which returns a nice table.

There are still a couple of issues.
First, if the text reference contains a wiki link, like "[[Link]]", then it
is not returned as a link, but just as text with the square brackets. It
would be nice to be able to have that as a link if it wants to be, and to
ignore it if not.
Secondly, how can I set the order of the index list? It seems to be random
at the moment. I'd like it to be in the order of the data in the tiddler,
or failing that, alphabetical.
Thirdly, is it possible to return the names of the values, and not the
values themselves? If that were possible, the a macro could be made which
would do something like this:

<<data-tiddler-table "[prefix[Job Number:]]">>

would give a table with the first row:

| data value 1 name | data value 2 name | data value 3 name | data value 4
name |

and then one row per returned tiddler with the form:

| data value 1 | data value 2 | data value 3 | data value 4 |

That would be very generally useful!
Post by Eric Shulman
Post by Matthew Petty
I am exploring the use of data dictionary tiddlers, and they seem to be
very useful as a way of having data stored in the text of a tiddler, rather
than in a field or tag.
- So the question is, is there a way to go through all the text
references in order and return their values? Then I could do a macro which
would return a row of a table, without having to specify the text
references.
You can use the indexes[] filter to get the names of the items in a data
http://tiddlywiki.com/#indexes%20Operator
<ul>
<$list filter="[prefix[Job Number:]]">
<$list filter="[<currentTiddler>indexes[]]" variable="thisIndex">
<li><$view index=<<thisIndex>>/></li>
</$list>
</$list>
</ul>
Note the use of variable="thisIndex"... this allows the inner $list to
loop through the items without changing the value of "currentTiddler" that
was set by the outer $list.
enjoy,
-e
Eric Shulman
TiddlyTools / ELS Design Studios
InsideTiddlyWiki: The Missing Manuals
--
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+***@googlegroups.com.
To post to this group, send email to ***@googlegroups.com.
Visit this group at https://groups.google.com/group/tiddlywiki.
To view this discussion on the web visit https://groups.google.com/d/msgid/tiddlywiki/69bcc23b-72b9-4641-b2d4-c1c9c09f35b1%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Eric Shulman
2016-03-28 14:12:57 UTC
Permalink
Post by Matthew Petty
Eric,
<table>
<$list filter="[prefix[Job Number:]]">
<tr><td>{{!!title}}</td><$list filter="[<currentTiddler>indexes[]]"
variable="thisIndex">
<td><$view index=<<thisIndex>>/></td>
</$list></tr></$list>
</table>
Which returns a nice table.
There are still a couple of issues.
First, if the text reference contains a wiki link, like "[[Link]]", then
it is not returned as a link, but just as text with the square brackets. It
would be nice to be able to have that as a link if it wants to be, and to
ignore it if not.
Instead of the <$view> widget, use
<$transclude index=<<thisIndex>>/>

This will cause the value to be "translated" before it is "included" in the
output (thus, "trans"+"clude"), so that any wiki syntax contained in the
value will be processed (e.g., [[foo]] will become a proper link to a
tiddler named "foo")
Post by Matthew Petty
Secondly, how can I set the order of the index list? It seems to be random
at the moment. I'd like it to be in the order of the data in the tiddler,
or failing that, alphabetical.
As noted in the documentation for
http://tiddlywiki.com/#indexes%20Operator, the names are returned "in no
particular order". However, as with any filter result, you can apply a
[sort[]] operator to change the order:
<currentTiddler>indexes[]sort[]

Thirdly, is it possible to return the names of the values, and not the
Post by Matthew Petty
values themselves? If that were possible, the a macro could be made which
The indexes[] operator IS already returning the names... not the values.
The actual values are retrieved by the <$view> (or <$transclude>) widget.
Assuming that all the "Job Number" tiddlers have the same index names,
you can write your table like this:

<table>
<$list filter="[prefix[Job Number:]limit[1]]">
<tr>
<td> <!-- EMPTY CORNER --> </td>
<$list filter="[<currentTiddler>indexes[]]" variable="thisIndex">
<td><<thisIndex>></td>
</$list>
</tr>
</$list>
<$list filter="[prefix[Job Number:]]">
<tr>
<td>{{!!title}}</td>
<$list filter="[<currentTiddler>indexes[]]" variable="thisIndex">
<td><$view index=<<thisIndex>>/></td>
</$list>
</tr>
</$list>
</table>

* The first $list widget retrieves ONE "Job Number" tiddler and uses it to
display the headings (the index names). Note the use of "limit[1]" so that
only one row of headings is shown.
* The second $list widget then retrieves ALL "Job Number" tiddlers and
displays a row for each tiddler, showing the index *values*.

Q.E.D

enjoy,
-e
Eric Shulman
TiddlyTools / ELS Design Studios
InsideTiddlyWiki: The Missing Manuals
--
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+***@googlegroups.com.
To post to this group, send email to ***@googlegroups.com.
Visit this group at https://groups.google.com/group/tiddlywiki.
To view this discussion on the web visit https://groups.google.com/d/msgid/tiddlywiki/9fd2ef45-fc54-4686-a56c-dc77a0329530%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Matthew Petty
2016-03-28 19:57:23 UTC
Permalink
Eric,
Thanks again for your clear explanation and patience!
1. Transclude instead of view - of course, makes sense.
2. I did see the sort option, but couldn't figure out what should go in the
brackets. Then you showed me that nothing goes in the brackets - the only
available sorts are alphabetical, or reverse. So I renamed my indexes to
have numbers, so they sort alphabetically how I want them: jn_01_company,
jn_02 etc
3. Aha! I wasn't aware of the limit operator. Clever solution.

My table now shows what I want, and I easily add more rows, and create that
macro if I want.

I was also able to use edit-text widgets to be able to edit the values
directly.

Thanks again, you're most kind.
Best regards,
Matthew Petty
+971 56 622 1318
Post by Eric Shulman
Post by Matthew Petty
Eric,
<table>
<$list filter="[prefix[Job Number:]]">
<tr><td>{{!!title}}</td><$list filter="[<currentTiddler>indexes[]]"
variable="thisIndex">
<td><$view index=<<thisIndex>>/></td>
</$list></tr></$list>
</table>
Which returns a nice table.
There are still a couple of issues.
First, if the text reference contains a wiki link, like "[[Link]]", then
it is not returned as a link, but just as text with the square brackets. It
would be nice to be able to have that as a link if it wants to be, and to
ignore it if not.
Instead of the <$view> widget, use
<$transclude index=<<thisIndex>>/>
This will cause the value to be "translated" before it is "included" in
the output (thus, "trans"+"clude"), so that any wiki syntax contained in
the value will be processed (e.g., [[foo]] will become a proper link to a
tiddler named "foo")
Post by Matthew Petty
Secondly, how can I set the order of the index list? It seems to be
random at the moment. I'd like it to be in the order of the data in the
tiddler, or failing that, alphabetical.
As noted in the documentation for
http://tiddlywiki.com/#indexes%20Operator, the names are returned "in no
particular order". However, as with any filter result, you can apply a
<currentTiddler>indexes[]sort[]
Thirdly, is it possible to return the names of the values, and not the
Post by Matthew Petty
values themselves? If that were possible, the a macro could be made which
The indexes[] operator IS already returning the names... not the values.
The actual values are retrieved by the <$view> (or <$transclude>) widget.
Assuming that all the "Job Number" tiddlers have the same index names,
<table>
<$list filter="[prefix[Job Number:]limit[1]]">
<tr>
<td> <!-- EMPTY CORNER --> </td>
<$list filter="[<currentTiddler>indexes[]]" variable="thisIndex">
<td><<thisIndex>></td>
</$list>
</tr>
</$list>
<$list filter="[prefix[Job Number:]]">
<tr>
<td>{{!!title}}</td>
<$list filter="[<currentTiddler>indexes[]]" variable="thisIndex">
<td><$view index=<<thisIndex>>/></td>
</$list>
</tr>
</$list>
</table>
* The first $list widget retrieves ONE "Job Number" tiddler and uses it to
display the headings (the index names). Note the use of "limit[1]" so that
only one row of headings is shown.
* The second $list widget then retrieves ALL "Job Number" tiddlers and
displays a row for each tiddler, showing the index *values*.
Q.E.D
enjoy,
-e
Eric Shulman
TiddlyTools / ELS Design Studios
InsideTiddlyWiki: The Missing Manuals
--
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+***@googlegroups.com.
To post to this group, send email to ***@googlegroups.com.
Visit this group at https://groups.google.com/group/tiddlywiki.
To view this discussion on the web visit https://groups.google.com/d/msgid/tiddlywiki/652cad61-8aee-48d3-b1b8-11ad3e64bc28%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Continue reading on narkive:
Loading...