It has been asked several times in the forum: how to produce a list as a comma separated, or pipe separated, etc.
Here I propose some solution and welcome contributions and experiences for such cases.
It has been asked several times in the forum: how to produce a list as a comma separated, or pipe separated, etc.
Here I propose some solution and welcome contributions and experiences for such cases.
Here only a text (static) values are required with a delimiter!
$:/tags/Macro
\define dlist(filter, delimiter:", ")
<$list filter="$filter$ +[join[$delimiter$]]">
<$text text=<<currentTiddler>> />
</$list>
\end
Testing
Learning
and separated with comma!<<dlist "[tag[Learning]limit[4]]">>
produces
Videos, Introduction to filter notation, Sharing a TiddlyWiki on Dropbox, Sharing your tiddlers with others
About
and separated with pipe (|
)!<<dlist "[tag[About]]" " | ">>
produces
Acknowledgements | Contributors | History of TiddlyWiki | License | Releases | RoadMap
Here the outputs are links and separated with specified delimiter
$:/tags/Macro
\define dlist-link(filter, delimiter:", ")
<$list filter="$filter$ +[butlast[]]"><$link/>$delimiter$</$list>
<$list filter="$filter$ +[last[]]"><$link/></$list>
\end
Testing
Learning
and separated with comma!<<dlist-link "[tag[Learning]limit[3]]">>
produces
Videos, Introduction to filter notation, Sharing a TiddlyWiki on Dropbox
About
and separated with pipe (|
)!<<dlist-link "[tag[About]]" " | ">>
produces
Acknowledgements | Contributors | History of TiddlyWiki | License | Releases | RoadMap
Hi Mohammad,
Very interesting and useful macros. Thank you very much!
I think that the macro calls in case 2 / Testing should be dlist-link
. In paragraph 2 you put a space before the hyphen, and in paragraph 3, you wrote dlist-list
.
Could you please edit your own post? Just in case some users might copy-paste your solution without checking and wonder why it doesn’t work. Thanks!
Helpful! … So, Under the “no good deed goes unpunished” heading:
Could you see how to extend this logic so that a list-field column in your Shiraz dynamic tables could be made to display field contents in this delimited format? (I have many multi-word titles, and my current workaround is to alter stylesheet so that a.tc-tiddlylink has a bit of extra padding at left, so that I can easily see the gaps between listed items in dynamic table column in view mode. This would clearly be much better!)
Springer
Do you mean a table column shows the list field as dlist-link format?
If I am correct, then yes, it is possible! You need to develop a column template!
Give a try and if you failed (you wont! ) then let me know to write one for you!
Just thought I would add this approach;
<$set name=total filter="[tag[Macros]sort[title]count[]]">
<$list filter="[tag[Macros]sort[title]]" counter=item><$link/>{{{ [<item>!match<total>then[, ]else[.]] }}}</$list>
</$set>