Hi @lateralus123, I’m glad to see you found a solution that meets your needs! I just wanted to say that is is possible (and not too difficult!) to customize the way a column displays in a Shiraz dynamic table. Mohammed wrote up a basic tutorial that you can refer to, but very briefly:
If the field that needs a special display is is reference…
- Make a tiddler that will serve as the template for each cell in the reference column. Dynamic tables use tags to find the appropriate templates, so the title of this template can be whatever you want. I’ll go with “DynamicTablesBodyLink”.
- Give your new tiddler the tag
$:/tags/Table/BodyTemplate
because it will be used for cells in the body of the table. (Similarly, you would use $:/tags/Table/HeaderTemplate
to add a custom header for a specific column, or $:/tags/Table/FooterTemplate
for a custom footer.)
- Add a field called
tbl-column-list
which contains the space-separated names of any fields that should be displayed with this special template. At minimum, it should include reference
.
Mohammed advises building your cell templates to account for both edit and view mode as well as sorting, so his sample templates look quite complex. However, if you don’t need to be able to edit these cells, the contents of this template tiddler can be very simple:
<td> <!-- generates a table cell-->
<$link to={{{ [<currentRecord>get<currentColumn>] }}} />
</td>
Within the dynamic tables macro, <<currentRecord>>
refers to each tiddler displayed as a row in the table. <<currentColumn>>
obviously refers to the current column, which will generally be the name of the field being rendered (though it doesn’t have to be, as you can see in special columns like tbl-expand
). So if the reference field contains only the name of the reference tiddler without square brackets, each reference cell will display a link to that tiddler.
If you do want to preserve the in-table editing functionality, it’s just a bit more complicated. This is adapted from the default body template and Mohammed’s upcoming Shiraz 3.0 rewrite, so it uses TW 5.3.2+ conditional syntax (rather than $reveal widgets) and the <<editCell>>
macro from Shiraz 2.9.7.
You can see that I’m also using the same link syntax here as the contents of the cell when it’s not in edit mode.
\procedure link()
<$link to={{{ [<currentRecord>get<currentColumn>] }}} />
\end
<td>
<%if [<tempTableEdit>is[missing]] :or[<tempTableEdit>getindex[mode]!match[edit]] %>
<<link>>
<%elseif [<tempTableSort>getindex[sortIndex]match<currentColumn>] %><!--check if the current column is not selected for sorting-->
<<link>>
<%else%>
<<editCell>>
<%endif%>
</td>
I know this seems like a lot of work when you already having a functioning solution (just put the wikitext link in the field!) but I hope it may be helpful if you want to do anything more complicated with dynamic tables in the future. I’d also like to second Eric’s very sound advice to keep your field contents free of wikitext whenever possible—and I say this as someone who really should have heard it in my early days and didn’t.
Lastly, if you use Discord, you should join us on the TiddlyWiki 5 server, which seems to have the most active TW-for-TTRPGs community at present!