If I want to autoset my icon field base on my tags when submit a tid where should I start?

If I want to autoset my icon field base on my tags. For example I just create a tid with 3 tags “a b c”. Tags a,c dont have icon filed itself, just b have.

Something like this:


I want the current tid icon field auto set to the icon of “todo”

  1. I want the icon field auto set to first tag with icon (like todo’s icon) in this case
  2. do nothing if the current tid already have icon field.

The most important thing I need to know is:
How to trigger a custom event when submit the current tid?

1 Like

When you

you are clicking the editor done button.

I have created an alternate save button “alt-save” alt-save-button.json (1.3 KB) which you can install and edit it to add your addtional actions see <!-- place your action widgets here -->

  • Goto the Edit toolbar and hide the original save button and show only the new one.
  • At least for now, I will leave the logic and actions to identify the icon and set the icon field to you.
    • I suggest only setting the icon field if it is empty so if a manual one was set, or every time you save a tiddler it does not set it again (but I need to retest the save tiddler).

I have a demo solution that allows you to add actions to any button simply using a tag https://all-button-actions.tiddlyhost.com/

Background;
The editors done button, can be found here $:/core/ui/Buttons/save if you look in this button you will see the button has <<save-tiddler-actions>> in its body. This happens to be defined in $:/core/ui/EditTemplate. Rather than modify another core tiddler I copied this into a replacement button so we can redefine it there. Resulting in the above tiddler and instructions.

Since tags are always sorted alphabetically you can’t define which tag is the first one. So there is no reliable way to do that atm

I personally would “hook” into the edit-template tag-pill. … If you click the tag-pill in edit-view, you’ll see, that nothing happens.

So it should be possible to create a custom tag-pill, that opens a dropdown with a “use this icon” element. So it wouldn’t be automatic, but only 2 clicks and most importantly predictable.

The edit-tag template will be the starting point. Search for tc-tag-label tc-tag-list-item to find the element that is responsible for the tag pill.

Ori, I’m replying here with an alternative, even though you may be happy with the icon-setting solution on tiddler save. Depending on use-purposes, you – or others – might prefer a css-only solution, as described below:

A stylesheet can be set to display a visual icon (or virtually anything else you can imagine) before tiddler links (which affects title display in story river if you use setting to display tiddler titles as links). You can use filters (including tag-based filters) to choose which tiddlers get styled in which ways…

The basic stylesheet and explanation is here: http://linkstyle.tiddlyspot.com/ (Note that one can specify not only what’s before the link, but also the link styling itself, and also what might come after the link.)

To see wikis where tag-based icons are shown in this way (without using the icon field), check these out:

The first of these is rather old, and the refnotes plugin has been much developed since then, but it was my first attempt to implement a tag-based linkstyle solution, and includes a bit of an explanation of how it works.

Cheers!
-Springer

2 Likes

If you use Tiddlywiki 5.2.1+, then the simplest is to use cascades! Look at https://tiddlywiki.com/#Cascades and try provided examples.

1 Like