Transclusion to missing tiddlers idea?

Make a tid with a title like “placeholder” and in the body have…

<$transclude><$link/></$transclude>

In the article tid, put:

{{LinkTitle||placeholder}}

1 Like

One workaround would be to do the following:

In the article, paste <$link>*</$link> (or just <$link/>), then excise it and give it a title.

1 Like

ooh this is a really nice solution! I imagine your brain spinning radically in circles producing solutions!

1 Like

To extrapolate on @Brian_Radspinner idea. If you always transclude using a template, then you can leverage the template to show some empty placeholder.

I always transclude using a custom template which shows me two small buttons, view and edit, along with every transcluded text.

If the tiddler is empty, the buttons still appear, which gives me a cue that a transcluded tiddler is missing.

I use the snippet feature to make it easy to insert the template.

3 Likes

Nice idea! Could you share what you put in that template?

$__talha131_Template_NavigateTranscludedTiddler.json (1.1 KB)

I had asked about this in this thread. It has some great answers.

6 Likes

This is amazing. Beautiful, thanks for sharing!

This is an excellent question and these are excellent solutions. I’ve also had this exact problem for a while now, so I’m glad to know I’m not the only one. Perhaps we should make a macro for this?

I find that creating a template that you use to transclude any tiddler name allows you to include logic in the template to meet any requirement.

For example create this tiddler “smart”.

<$list filter="[all[current]!has[text]]"><$link/></$list>
<$list filter="[all[current]has[text]]">
   <$transclude/>
   <$list filter="[{$:/config/design-mode}match[yes]]">
       {{||$:/core/ui/Buttons/edit}}
   </$list>
</$list>

Also create a tiddler $:/config/design-mode set to yes

Now you can use the following transclusion {{New tiddler without content||smart}}.

  • Now if the tiddler is missing you get a missing tiddler link
  • If the tiddler is available it is transcluded
  • If the design-mode is yes provide a link to edit the tiddler

The smart tiddler can be packed with all kinds of features including tooltips, buttons and more logic.

  • Using the config tiddler method you can switch various behaviours as needed.
  • An editor toolbar button to apply {{ selection ||smart}} or any "smart transclusion tiddler, would be helpful.
2 Likes

Most of times, I find that I want to be able to edit simply the transcluded content. And similarly to what have already been told, I do something like:

!! <$link to=<<transcuded>>/>
<$transclude mode=block tiddler=<<transcluded>>/>
1 Like

Here’s a simple ‘preview transclusion’ macro that enables non-existent transclusions to be created as links initially, then into text transclusions on adding text in the aforementioned linked tiddlers. One could improve this further by adding some small link ‘decoration’ to the transcluded text to allow further editing of the transcluded tiddler:

\define ptransclusion(title)
<$set name="var" tiddler=<<__title__>> field="text" emptyValue="[[$title$]]">
<<var>>
</$set>
\end

With the above macro, the following will yield a wikilink to as yet unpopulated tiddler titled ‘title’:

<<ptransclusion "title">>

Adding text to that tiddler e.g. Hello world will cause the link to be replaced by the contents of tiddler titled ‘title’.

1 Like

The idea of being able to show a clickable message for missing transclusions is very interesting.

There’s no easy way to accomplish this with the current core. I can see two possible implementation approaches, both of which would require JS modifications in the core:

  1. Change the parse rules for the shortcut syntax {{tiddler}} to generate additional code that substitutes the value of a global like tv-missing-transclusion in case the tiddler is missing. Something like <$transclude tiddler={{{ [<targetTiddler>is[missing]then<tv-missing-transclusion>else<targetTiddler>] }}}...
  2. Change the transclude widget along the same lines: to magically replace the target tiddler title with the value of tv-missing-transclusionif it doesn’t exist

The second would appear to be more efficient, but adds yet more complexity to the transclude widget, which is already about to get more complex when #6666 is merged.

The parameterised transclusion work in #6666 would provide another way to approach this: a custom widget could override the transclude widget and wrap it in the functionality outlined above. There’s an existing example of overriding the transclude widget in the pre-pre-release that could be used as the basis for this:

https://tiddlywiki.com/prerelease/parameterised-transclusions/#Visible%20Transclusions

When you click the button it creates a temporary tiddler tagged $:/tags/Macro/ViewTemplateBody containing the redefinition. Thus the modification only applies to tiddler content, and not to TiddlyWiki the user interface itself.

3 Likes

Thanks for the pointers Jeremy. It’s great to see transclusion becoming more useful with these core additions. I especially love the idea of making them visible and clickable for instant editing. This is some fine work.

What I would love to see and have personally are draggable transclusion blocks that I can drag around and attach to whatever tiddler text body I’m reading amd modifying on the fly. Oh, now that would be a minority report moment: dragging around and assembling pieces of reusable data ala no code style :bulb:

1 Like

You could set that up today with a custom template for transclusions that uses the draggable widget or provides draggable links, and a custom view template that uses the droppable widget. That would make for a fun wikitext based project for someone inclined to do some tinkering.

2 Likes

Yes, I was thinking along similar lines. Let’s see what we can cook up…

1 Like

You could also do something similar today with Streams, though that is overkill since you likely would not be using a lot of the features related to hierarchies, keyboard handling and creation of new tiddlers.

Not at all @saqimtiaz. I use Streams extensively and I see what you’re getting at, but what I’d like do to is have this capability outside of the semistructured, outline paradigm of Streams, because I do like constructing essays out of different atomic ideas from the past.

1 Like

Personally I like how Tiddlers currently manage tranclusions in core for missing tiddlers as it works for one of my purposes.

It means you can have sensative information of a topic in a seperate tiddler and use transulation to place it in the main article. You can then share a redacted version of the wiki simply by deleting all the tiddlers tagged as sensative in the copy. It would not be obvious that anything is missing unless someone goes looking (edit mode) for it.

2 Likes

Welcome to the community @Alan_101. That’s an important point and I’m sure we’ll work to preserve that behavior in subsequent updates.

There are a number of workarounds and possible futures discussed here, but the current out of the box behaviour has its purpose, and there are plentiful alternatives already.

  • Have a deeper look at my example above if you have not
  • This is a design pattern that solves the OT and is highly extensible
  • The inclusion of a switch, in my example the design-mode also allows for toggling the behaviour on/off
  • other example are similar to my own.
  • new innovations coming will only extend this pattern further.

Tony