How to modify tag-picker macro to store values in a different list

Hello all,

The tag-picker macro macro has the option to select a field to store the values you input in. The default is ‘tags’ ofcourse, but using this you can also use the tag-picker as a people picker for example and store whatever you input in a field called ‘people’.

What doesn’t work at the moment with fields other than ‘tags’, is the dropdown of previously selected values. Using the people-picker example. When I put in ‘person A’, this value isn’t added to the list, and thus you will have to write it each time after.

Is it possible to modify the tag-picker macro to have it store persons in a different list, so when I use it to fill in the people field it uses those values only?

With kind regards,
Odin

1 Like

@Odin I had not looked at this before but looking now it seems the drop down still only searches existing tags, so so it is more an alternative field storage for tags rather than a separate people/tag system.

The @inmysocks GitHub - OokTech/TW5-GenTags: Let any field act like a tags field in TiddlyWiki solution allows a full alternative tag solution, with all the support tools. Editor, Filters etc…

However what you are asking is only slightly different to the standard behaviour so let us look at the macro as its defined $:/core/macros/tag-picker and consider a revised form.

I will update this reply as I continue

Notes:

  • In the tag picker dropdown we see the tags that match the text entry above the line.
  • What is missing in your example is there are no system tiddlers containing “first”.
  • In the macros we sewe the following filters
    nonSystemTagsFilter="[tags[]!is[system]search:title<userInput>sort[]]" systemTagsFilter="[tags[]is[system]search:title<userInput>sort[]]
    this shows how the drop down is populated using tags[] and this is will not find past people only past tags. Ideally we could rewrite this to continue working for tags but also the given “tagField”
  • I note with your example <<tag-picker tagField:"people">> that when you add a “tag tiddler to the people field” with a click on an item in the dropdown list there is little feedback.

Hi @Odin,

I have an idea, which would also be suitable for the core. I’ll post it here when I’m back on my pc

1 Like

I am working on a way to pass alternate filters into the picker.

2 Likes

@BurningTreeC @TW_Tones
Bit late of a reply, but did you end up finding a solution?

Looking at the code of this macro, it seems the filters that generate the list of system and non-system tags is hardcoded in the third <$vars/> inside the macro tag-picker-inner()`:

nonSystemTagsFilter="[tags[]!is[system]search:title<userInput>sort[]]"
systemTagsFilter="[tags[]is[system]search:title<userInput>sort[]]"

Which are later processed with mostly identical wikitext:

<$set name="userInput" value={{{ [<storeTitle>get[text]] }}}>
...
</$set>

So if I understand your needs correctly, you want to be able to provide custom list of items to use instead of the list of tags, that is replace the value of both nonSystemTagsFilter and systemTagsFilter.

This could be accomplished by adding two new arguments to the macro that would default to these default values if not given.

I have completed a tiddler-picker to add a title to fields or tags based on the EditorToolbar Link button. I am yet to recode the tiddler picker to accept a sub filter.

  • I could include a method to add titles to a list field

Search talk.tiddlywiki.org for “picker” to find other discussions.

  • This is a desirable outcome and I have attempted to hack it, but the keyboard handling makes it more complex.

Ideally there would be a title/search macro that allowed subfilters and triggered actions that we could use to set field/tags/list fields etc… from the user selected titles. Basically extract and generalise the content of the tag-picker Macro.

Thank you! Changing these filters changed the list, which makes it already workable for me!

1 Like