Hacking tbl-expand (with templates) in shiraz dynamic tables

Having begun to orient to cascades, I wonder about their power in all sorts of situations.

One is within @Mohammad’s Shiraz dynamic tables. Out of the box, the table-dynamic macro offers a tbl-expand column, which renders as a drop-down caret to peek at the tiddler’s contents (meaning its wikified text field).

I’ve discovered how I could hack the shadow tiddler in order to display something else (such as a view template that draws on various fields) when the expansion caret is toggled. The relevant shadow tiddler is

$:/plugins/kookma/shiraz/macros/dtables/tbl-expand

The key line (what shows if getindex[mode]match[edit] is empty) is this one:

"""<$transclude tiddler=<<currentRecord>> field=text mode=block/>"""

I can replace that bit with a list widget that specifies a template. As Proof-of-Concept, I swapped in my “p-overview” template (already in action as a View Template):

emptyMessage="""<$list filter=<<currentRecord>> template="p-overview" mode=block/>"""

Of course, this brute hack affects dynamic tables throughout the wiki!

And if I try to build a filter that is responsive to more than a simple condition, I imagine the code will get messy quickly.

So, could there be a cascade solution here?

In theory, I imagine a future table-dynamic macro could include a parameter for “expand-template” (or something like that).

But one could even imagine – within the same table – a responsive tbl-expand solution that would be informed by facts about any currentRow. So it migth display code for code-body:yes tiddlers, a font-preview template for font-tagged tiddlers, etc., according to some cascade of conditions…

How far out in left field is this?

If it’s out of reach with current builds of TiddlyWiki and Shiraz, is there some other elegant way that dynamic tables could reveal different template-based tbl-expand contents for different situations?

-Springer

3 Likes

I believe in the long run the use of cascade is the solution, but let’s see what other solutions are proposed.

1 Like

You may get more ideas if this question of @Springer’s is reduce to a simpler example, otherwise its just your deep understanding of shiraz dynamic tables that may be needed.

Hi @TW_Tones

I reposted the question by @Springer in a simple language in

Use Cascades for Custom Transclusion - Discussion - Talk TW (tiddlywiki.org)

The solution has other use cases.

Thanks! I’ll see what I can do with the path forward that @saqimtiaz outlined on that thread, and post a follow-up here with a link to a demo of a solution in action for dynamic tables.

1 Like

Yes, please go with Saq solution and share here!

I added a ticket for Shiraz 3.0 (will be available after TW 5.3.0)

1 Like

Sorry for the delay! Happy to report that tbl-expand in dynamic tables (in Shiraz by @Mohammad) is fantastic if you hack it to follow existing view & edit cascades.

Find this shadow tiddler:

$:/plugins/kookma/shiraz/macros/dtables/tbl-expand

And replace its contents with the following:

\define display-expanded-record()
<td colspan=<<ncols>> class="shiraz-dtable-expanded-record">
<$tiddler tiddler=<<currentRecord>> >

<$list filter="[<tempTableEdit>getindex[mode]match[edit]]" variable=ignore>
{{||$:/core/ui/EditTemplate/body}}
</$list>

<$list filter="[<tempTableEdit>getindex[mode]match[view]]" variable=ignore>
{{||$:/core/ui/ViewTemplate/body}}
</$list>

</$tiddler>
</td>
\end

Before doing this, I also imported @TW_Tones cascade tweak here; I’m not sure whether that was necessary to making the whole package work smoothly.

Honestly, I thought it was going to involve some cascade-specific learning curve (beyond what I already was doing in the control panel for regular story-river purposes). Nope! The cascade action happens “behind” the core view and edit templates. Brilliantly simple.

@Mohammad — this strikes me as a pretty straightforward default behavior, no?

If someone’s got custom view and edit templates for recipes, or contacts, or tasks, or whatever, all of them should now just work when they’re accessed within a dynamic table. :smiley:

PLUS: Side benefit: if you edit within a dynamic table, you’re not editing a “draft-of”. This is convenient when your corresponding view template invokes the tiddler’s title in a filter (such as a dynamic table with [all[current]listed[]] condition) — within the expanded dynamic table row, you can keep the edit preview pane open, and see your changes “live” in the preview pane — as they will appear with the corresponding template applied.

:rocket:

-Springer

2 Likes

Hi Springer,
What you developed uses the TW cascades and show tiddlers (records) in edit and view mode based on globla Cascades setting under $:/ControlPanel/Ifo/Advanced/Cascades. So you have the same look and feel as story river.

There is a side effect here even with current version of Shiraz (2.7.7). When you edit a tiddler which triggers a refresh like a tiddler tagged with $:/tags/Macro you will lose focus. There are other tiddlers that direct editing them causes page refresh.

1 Like

An update is pushed to reflect the new tbl-expand!
Thank you @Springer

2 Likes