Link color field values

I’m using two tags, book and audiobook. I want the latter to get its color field value from the former. I’ve tried setting audiobook's color field value to {{book!!color}} but it doesn’t work, though it looks like it should work:

What am I missing?

My guess is that your setting results in the value to literally be the transclusion rather than then evaluated transclusion.

I would think that you can get around this by not actually setting the color field for the latter but using a separate stylesheet to enforce the transcluded color. Basically something along the lines of

tags: $:/tags/Stylesheet
type: (don't set this to text/css, leave it empty)
text:
\define ab-col() [data-tag-title] {background: $(color)$; }

<$let color={{book!!color}} >
<<ab-col>>
</$let>

I didn’t try the above but something along those lines should work. Maybe others have a better idea.

This is exactly the case, because the color field value is not wikified, so transclusions don’t work there.

HOWEVER…here’s a little trick that does work:

The $:/config/TiddlerColourFilters/color-field shadow tiddler defines a filter that is used in a cascade to determine when to apply the !!color field value to a tiddler. By default, this shadow tiddler contains:

[has[color]then{!!color}]

Edit this shadow tiddler and change the filter definition to:

[get[color]removeprefix[{{]split[!!]first[]get[color]] ~[has[color]then{!!color}]

What this does:

  • Get the color field value. Note that get[color] only returns a value if the color field has a non-blank value, so it implicitly applies the has[color] test.
  • Look for a {{ prefix in the color field value and remove it.
  • Split the remaining field value at the !! and take the first[] part to get the title of the tiddler being “transcluded”
  • Then, get the color field value from that tiddler

Note that, if the tiddler doesn’t have a color field value, or that value doesn’t start with {{, or the referenced tiddler doesn’t have a color field, or that color field value is blank, then the filter uses the previously defined TWCore standard test for when to apply a color field value.

Let me know how it goes…

enjoy,
-e

It worked!

I do feel a little uneasy editing a shadow tiddler for something this trivial tbh. I’m not confident enough with TW’s inner workings, it’s not clear to me what else would be affected by this change.

Would it be possible to use something to wikify the {{book!!color}} in-place, so the actual color value would be passed without fiddling with the system’s internals?