Display the cascades used for a given tiddler

If, like @Springer (and @TW_Tones?) and me, you do a lot of work with cascades, you may have had the question I have semi-regularly: Which template tiddler is being used to render this one? (And how do I quickly access it to make changes?)

After going into the Control Panel one too many times just to work out the answer, it finally occurred to me that I could present this information on the tiddler itself. Here’s the template I came up with, ready for testing on TW-com or in your own wiki: Tiddler Cascade Info.tid (1.2 KB)

Raw code under the fold
tags: $:/tags/TiddlerInfo/Advanced
title: $:/emt/ui/TiddlerInfo/Advanced/CascadeInfo

\procedure cascade(label, tag)

\define cascade-filter() [{!!title}] :cascade[all[shadows+tiddlers]tag<tag>!is[draft]get[text]] +[!is[blank]]
\function get.filter() [{!!title}get[text]]
\function using.filter() [all[shadows+tiddlers]tag<tag>!is[draft]] :filter[<..currentTiddler>filter<get.filter>]

\function config() [<tag>trim:suffix[Filter]trim:suffix[Template]search-replace[tags/],[core/ui/ControlPanel/]]

<tr>
	<td><$link to=<<config>>>''<<label>>''</$link></td>
	<td><$list filter=<<cascade-filter>> emptyMessage="//none//" /></td>
	<td><$link to=<<using.filter>> /></td>
</tr>
\end

<br>''Cascade Info''

Currently using the following cascade templates:

<table>
<tr>
	<th>Cascade</th>
	<th>In use</th>
	<th>Source filter</th>
</tr>
<<cascade "Story Tiddler Template" $:/tags/StoryTiddlerTemplateFilter>>
<<cascade "View Template Title" $:/tags/ViewTemplateTitleFilter>>
<<cascade "View Template Body" $:/tags/ViewTemplateBodyFilter>>
<<cascade "Edit Template Body" $:/tags/EditTemplateBodyFilter>>
<<cascade "Tiddler Icon" $:/tags/TiddlerIconFilter>>
<<cascade "Tiddler Colour" $:/tags/TiddlerColourFilter>>
</table>

Bonus: it also works for missing or “virtual” tiddlers!

I chose to display my template as part of the “Advanced” tab in the tiddler info section…

But if you’d prefer it somewhere more visible, you can replace the $:/tags/TiddlerInfo/Advanced tag — e.g., with $:/tags/ViewTemplate to make it a default ViewTemplate section — or incorporate it elsewhere (as in @TW_Tonestiddler card system?)

Please feel free to use this however you like, and let me know if you think of any clever enhancements!

1 Like

@etardiff lovey work. Perhaps you could submit a version of this as a core enhancement? It has previously been suggested as a desirable improvement.

1 Like

Cool!

I had been manually adding a field called in-cascade to anything template-like, because I wanted to make sure I could easily reconstruct these relations, since backlinks don’t easily read inside filters. (Maybe this is the opposite of your direction of concern, but related!)

I also started including a tiny template-link icon tucked into most of my templates. During the tinkering phase of a project they’re so handy! (EDIT: But only if the template is actually showing!)

[I’ll take a closer look at your approach! …]

FOLLOW-UP: I love that tucking all this into the info panel makes it available no matter what other weirdness has been happening with my view templates. So often, when a template isn’t showing, it takes a while to navigate to the right cascade-tag for checking / reordering. The fact that this table is packed with these links makes troubleshooting is much more friendly.

1 Like

That’s serendipitous! I’m not sure what modifications would be needed for the core (<<lingo>> macros at minimum, I imagine?), and even less sure I have time to relearn how to use GitHub right now. :sweat_smile: But I left a comment in hopes that it might be a good jumping-off point, at least. Thank you for bringing it to my attention!

1 Like
tiny fix was needed, now done

Somehow at least one cascade condition isn’t connecting properly… I’m set up to display a tag-pill in titlebar if the tiddler functions as a tag. The “in use” heading captures the tag template properly, but the source filter is missing the active filter, and instead yielding the cascade-condition that’s one further down the chain (in this case, the filter that prefers the caption if there is one)…

Interesting, I hadn’t noticed that one! I admit I haven’t yet worked out why it’s happening, but I think replacing

\function using.filter() [all[shadows+tiddlers]tag<tag>!is[draft]] :filter[<..currentTiddler>subfilter<get.filter>]

with

\function using.filter() [all[shadows+tiddlers]tag<tag>!is[draft]] :filter[<..currentTiddler>filter<get.filter>]

(that is, replacing subfilter with filter) yields the correct results. If you can confirm all looks good on your end, I’ll update my OP as well. Now updated in the .tid file and the codeblock, both in my OP here and in my GH comment. Thank you for catching that!

1 Like

That seems to clear it up!