How to make a composite table by transcluding wikitext tables from multiple tiddlers

Hi Experts,

I have some tiddlers with different content and want to combine them in an overview by using the { brackets

{{Tiddler1}}
{{Tiddler2}}
{{Tiddler3}}
Tiddler1
AAAAA
Tiddler2
BBBBB
Tiddler3
CCCCC

Result

AAAAA

BBBBB

CCCCC

That works fine so far but there is always an additional line break in the result.
Is it possible the avoid this?

Thx in advance for all solutions and help
Stefan

{{Tiddler1}}{{Tiddler2}}{{Tiddler3}}
{{Tiddler1}}<br>{{Tiddler2}}<br>{{Tiddler3}}

Hi @pmario,

thank you for your quick answer.
Works so far.
Do you have also a solution if the tiddlers contain tables?

Tiddler1
|myclass|k
|A1|A2|A3|
Tiddler2
|myclass|k
|B1|B2|B3|
Tiddler3
|myclass|k
|C1|C2|C3|

Result

|myclass|k |A1|A2|A3||myclass|k |B1|B2|B3||myclass|k |C1|C2|C3|

Thank you for your support
Stefan

1 Like

You’ll need to use the transclusion widget in block mode.

<$transclude $tiddler="Tiddler1" mode="block"/>...

See: https://tiddlywiki.com/#TranscludeWidget


SideNote: To indicate that the code block contains a tiddler we use the .tid format.

title: Tiddler3

|myclass|k
|C1|C2|C3|

So we can do this

title: test-tiddler
tags: [[aa bb]] cc

some text

You can also do this, if you “template” does not contain any plain text elements.
See: https://tiddlywiki.com/#Pragma%3A%20\whitespace

\whitespace trim

<$transclude $tiddler="Tiddler1" mode="block"/>

<$transclude $tiddler="Tiddler2" mode="block"/>

Hi @pmario,

I tried your transclude solution bit it failed :cry:

image

title: Result

\whitespace trim

<$transclude $tiddler="Tiddler1" mode="block"/>

<$transclude $tiddler="Tiddler2" mode="block"/>

<$transclude $tiddler="Tiddler3" mode="block"/>

Is there something wrong in my code?
Stefan

2 Likes

It looks like you are trying to combine three tiddlers, each with their own table row?

Thew problem is if you put them into mode=block they will not be recognised as parts of the same table.

In each tiddler you also start the table again, try having only the row |C1|C2|C3|

Regardless if there is no way to combine the tables rows, you can use html tables.

If you dont have an answer tomorrow, I will show you.

The method I would use is the wrap the transclusions in triple double quotes, like so

"""
{{Tiddler1}}
{{Tiddler2}}
{{Tiddler3}}
"""

Edit: ah, just finished reading, for the tables, the way the wikitext is setup I don’t think it is able to do that. Though that would be cool.

Hi Stefan,
Your code seems to be right, but I think your expectations are wrong.

If you have 3 tiddlers and every tiddler contains a wikitext-table, you create 3 independent HTML tables.

So if you want to show only 1 table you’ll need to create the table dynamically. eg:

<table calss="myClass">
	<tbody>
		<$list filter="Tiddler1 Tiddler2 Tiddler3">
			<tr>
				<$transclude $tiddler=<<currentTiddler>> />
			</tr>
		</$list>
	</tbody>
</table>

and your tiddlers will need to look like this:

title: Tiddler1

<td>A1</td>
<td>A2</td>
<td>A2</td>

Info about the HTML TABLE can be found at: <table>: The Table element - HTML: HyperText Markup Language | MDN

I’d normally use HTML tables, as @pmario suggested; it will give you far more flexibility and control over both the table’s content and its presentation. However, if you really want to keep the wikitext tables, here’s a slightly hacky alternative:

<$let break="""
""">
<$list filter="A B C +[get[text]] +[join<break>]">
	<$transclude field="title" mode="block" />
</$list>
</$let>

Where each tiddler looks like this:

title: A

| A1 | A2 | A3 |
<!-- as many rows as you like -->

Again, I wouldn’t use this if you need complex tables or header/footer rows, but it is possible.

1 Like

Hi @etardiff,

I found a workaround to get the additional formatting information.

An addtional Tiddler is providing the information:

tags: xxx
title: Table_head

|myClass|k
| 111 | 222 | 333 |h

The result Tiddler looks now

title: Result

<$let break="""
""">
<$list filter="Table_head Tiddler1 Tiddler2 Tiddler3 +[get[text]] +[join<break>]">
	<$transclude field="title" mode="block" />
</$list>
</$let>

And now I got an additional incredible idea :laughing:

How to change the filter expression to filter all Tiddlers with a tag = “xxx” ??

tags: xxx
title: Tiddler1

|A1|A2|A3|
tags: xxx
title: Tiddler2

|B1|B2|B3|
tags: xxx
title: Tiddler1

|C1|C2|C3|

I tried without success this one :cry:

title: Result

<$let break="""
""">
<$list filter="tag=xxx +[get[text]] +[join<break>]">
	<$transclude field="title" mode="block" />
</$list>
</$let>

This is a clever solution!

[tag[xxx]] is the filter you need to collect all the tiddlers with the xxx tag. Here’s how you’d use it in context:

<$list filter="[tag[xxx]] +[get[text]] +[join<break>]">

Remember that by default, the “pieces” of your table will appear in the order they do in the “xxx” tag dropdown. This will default to alphabetical order by title, but you can drag and drop the titles in the dropdown list to reorder their display sequence.

  • For easy access to the tag dropdown, you can use <<tag xxx>> to add a tag pill to a tiddler.

If you need a more complicated sorting system, you’ll probably want to use the :sort filter run prefix or one of the sort filter operators (check the documentation on tw-com.) Any additional sorting should go after [tag[xxx]] but before +[get[text]]. For instance:

<$list filter="[tag[xxx]sort[caption]] +[get[text]] +[join<break>]">
<!--                    ^^^ to sort by the caption field, rather than the default tag sort -->

<$list filter="[tag[xxx]] :sort[get[caption]] +[get[text]] +[join<break>]">
<!--                       ^^^ to sort by the results of the following filter run, which will be applied to each input title -->

@stefan_from_germany, I took the liberty of editing the title of the thread to make it clear that you’re focusing on wikitext tables. I do like the approach you’ve settled on, and it may be useful for someone else in the future!

1 Like

THANK YOU SO MUCH @etardiff

1 Like

Of possible use: Tids-to-table. Note the “Demo 4” which is about merging tables via css.

Also might be useful reference is my recent post about table helper. Note that it functions by splitting wikitext tables, resorting and then reassembling them.

@stefan_from_germany,

Just for the sake of conversation, and for future novices browsing this thread:

Almost always, in my experience, a table makes sense because there’s structured data involved.

And when there’s structured data involved, you might be better off working with fields rather than creating markdown tables within your tiddlers.

That way, you can do all sorts of powerful stuff with, say, all the info that’s in your third column. Or you could in one quick gesture change the column order, add a column, etc., all without needing to go in and separately edit each of those tiddlers with the xxx tag.

Also, there are powerful solutions — such as Shiraz dynamic tables — that open up new dimensions for your interaction with the data in tiddler fields (such as being able to edit on the fly from the overview table, dynamic sorting, automatic counts and sums in footers, being able to use filter conditions to slice and dice what you’re looking at, etc.)

I say all this gently, realizing your post was a simple “how to…” question, and it has been answered with the help of @etardiff and others. In case you are interested in a conversation about the many powers opened up by working with fields, please do feel free to ask!

2 Likes

Hi @Springer,

you are right if the use case is flexible.
And if the users are able to manage it.
In my use case the content is more or less stable, only in different contexts all or only some of them need to be displayed.

Thank you for your input, it is always welcome and not misunderstood.

Stefan