Programmatic Tag Colors/Icons/Fields

93 views
Skip to first unread message

thor...@gmail.com

unread,
Oct 10, 2021, 9:13:07 PMOct 10
to TiddlyWiki
Hello all,

I've been reading Grok Tiddlywiki to help organize my own personal wiki. I'm starting to reach the point where I need to organize my tags better. 

I understand that the Tag Manager exists for this purpose, but I was hoping for something that allows me to sort tags into groups by colors, and icons programmatically.

For instance, I have tags specifically for technical links, like "math", "compilers", "comp_arch", that would all be perfect for a color and icon I use purely for "technical" tags, with a tiddler that shows me what colors map to which group. However, if I decide I don't like this color/icon, I want to be able to change a single tiddler, and all tags in the same group get the new color/icon. Is there a way to accomplish this with transclusion?

On a related note: is there a way in general to transclude from a tiddler such that the target tiddler inherits the fields of the source tiddler?

Charlie Veniot

unread,
Oct 10, 2021, 9:49:40 PMOct 10
to TiddlyWiki
G'day,

To personalize your organization of tags, it sounds like you to to tweak the $:/core/macros/tag tiddler .

For each tag, you'll need to create a tiddler, in which you can specify fields of information for each tag.  Fields that your custom $:/core/macros/tag tiddler can use for anything you could think of.

Although I have not customized that $:/core/macros/tag tiddler, I have played a little bit with setting up colors on some of my tags in one of my TiddlyWikis.  Check this link for very simple color customization: https://tiddlywiki-programming.neocities.org/CJ_TiddlyWikiProgramming.html#pFilterE

Say you have "Tag A", and it is itself tagged (or has a field) indicating "Tag A" is of the category "Group 1", your modified $:/core/macros/tag might do something of the lines of checking what category a tag is, and decide that the tag should have a category and icon that are found in fields of the tiddler called "Group1".

Something like that.

PMario

unread,
Oct 11, 2021, 6:30:54 AMOct 11
to TiddlyWiki
On Monday, October 11, 2021 at 3:13:07 AM UTC+2 thor...@gmail.com wrote:

On a related note: is there a way in general to transclude from a tiddler such that the target tiddler inherits the fields of the source tiddler?

Sorry no, that's not possible. ...

As a workaround, if you create a new tiddler you can use the "Clone" button in the "More" section of the tiddler toolbar. ... or ...
You can use the "New here" button, which will pre populate the tag of the new tiddler with the name of the "old" tiddler, where you used the button.

-mario

Charlie Veniot

unread,
Oct 11, 2021, 9:45:16 PMOct 11
to TiddlyWiki
Arg, I pointed you to the wrong shadow tiddler.   I should have suggested that you look at $:/core/ui/TagTemplate.

Apologies !

Please find attached a file for you to download, drag into TiddlyWiki.com, and study.

This is my way of setting up inheritance.

I have "Some Tiddler" tagged with "Tag Category 1".

I have the "Tag Category 1" tiddler (i.e. the tiddler that matches the tag) in which I've specified a "color" field and selected a color that will show for that tag.

I have "Some Other Tiddler" tagged with "Test Tag 1".

And I have the "Test Tag 1" tiddler (i.e. the tiddler that matches the tag) in which I've specified a "Tag_Category" field, and set the value of that field to "Tag Category 1".

The intent is this: when a tag's matching tiddler has a "Tag_Category" specified, I want that tiddler to inherit (well, use) the color specified in the tiddler specified in Tag_Category.  If the tag's matching tiddler does not have a "Tag_Category" field, then I want that tiddler to have the color specified in the color field.  If it has no color field, then it will have the default color for tags.

The magic happens in the edit I've made to the $:/core/ui/TagTemplate.

Look for: colour={{{ [<currentTiddler>get[Tag_Category]get[color]] [<currentTiddler>get[color]] +[first[]] }}}

The original code was:  colour={{!!color}}

Cheers, and Best wishes !

On Sunday, October 10, 2021 at 10:13:07 PM UTC-3 thor...@gmail.com wrote:
TagColorInheritance.json

Charlie Veniot

unread,
Oct 11, 2021, 9:51:21 PMOct 11
to TiddlyWiki
You may find that colour={{{ [<currentTiddler>get[Tag_Category]get[color]] [<currentTiddler>get[color]] +[last[]] }}} makes more sense?

i.e. "if I have a color specified and a Tag_Category that specified a color, my color overrides the category color.  Otherwise, I'll use the category color."

Something like that.

thor...@gmail.com

unread,
Nov 5, 2021, 10:13:48 PMNov 5
to TiddlyWiki
This took me a while to get back to, but CJ's approach works for me. To make things a bit more convenient, I updated the Tag Manager tiddler to include a category field. It could be nicer (like showing the correct color based on whether the tag-category or color field is in effect, and having pill boxes for categories), but it works for me for now.

I've attached my Tag Manager changes as well as a diff compared to the default tag manager (as of ~5.2.0). Have fun!

tag-manager.diff
$__TagManager.json

Charlie Veniot

unread,
Nov 5, 2021, 10:37:42 PMNov 5
to TiddlyWiki
G'day Thor,

Thanks for sharing!  That is some right good stuff, your customization Tag Manager.  Bravo!


"showing the correct color based on whether the tag-category or color field is in effect, and having pill boxes for categories"

That, when you get around to it: you must share, because that will be the cherry on the ice cream cake.

Cheers !
Reply all
Reply to author
Forward
0 new messages