Is there a way to automatically transclude certain Tiddlers?

Hi there,

I was wondering if there was a way to automatically transclude certain tiddlers. For a random example, let’s say that I’m in a chemistry class, and that I want one tiddler named “Chemistry Notes - All” that has ALL of my notes for that class (I’d never do this because it would be a really long tiddler, but it demonstrates my point). But in order to do that with my current knowledge, I’d have to manually go to “Chemistry Notes - All” and add a transclusion every time I have a new note. Would there be a way to, say, automatically transclude every note that I tag with “Chemistry Notes” instead?

Use something like this:

<$list filter="[tag[Chemistry Notes]]">
   <p><$transclude/></p>
</$list>

Notes:

  • The $list widget uses a filter with the tag[...] operator, where the value in brackets is the literal tag text you want to match.
  • For each matching tiddler, the $list widget sets the <<currentTiddler>> variable to the title of the tiddler.
  • The $transclude widget defaults to using the currentTiddler value for which tiddler to transclude.
  • The <p></p> syntax puts a paragraph break before/after each transcluded note.

You could also write something like this:

<$list filter="[tag[Chemistry Notes]]">
   <$link/>:<blockquote><$transclude/></blockquote>
</$list>

which would display a link to the tiddler title of each individual note, and then show the contents of that note within HTML blockquote formatting.

enjoy,
-e

1 Like

Super helpful, thank you!

So based on that, I’m realizing that one of the things I actually want to do might be simpler than I thought.

Basically, I’m looking to make a table of contents, but instead of just a link, I want a tag pill. I was going to go about this by making tiddlers with these tag pills displayed, tagging those tiddlers as “content” or something, and then transcluding all tiddlers tagged “content” using the method you laid out by tagging all of these. Is there an easier way to do this?

You should take a look at the Table-of-Contents Macros.

Basically, you define a “root” tag (e.g., “content”), and then tag a set of tiddlers with that root tag. Then, for each of those tiddlers, you can use that those titles as tags for other tiddlers, creating a hierarchical “tree” structure. Something like this:

content
  Tiddler A
    SomeThing
    SomeOtherThing
  Tiddler B
     ThisOne
     ThatOne
  Tiddler C
     AndSoOn

Where:
TiddlerA, TiddlerB, and TiddlerC are tagged with “content”
SomeThing and SomeOtherThing are tagged with “TiddlerA”
ThisOne and ThatOne are tagged with “TiddlerB”
AndSoOn is tagged with “TiddlerC”

Then, to show the entire “tree”, you can just write:

<<toc "content">>

and to show the tree with collapsible/expandable “branches”, you can write:

<<toc-selective-expandable "content">>

You can see an example of this usage by viewing the TableOfContents tiddler, which displays a collapsible tree view for all of the TiddlyWiki documentation.

enjoy,
-e