When I try to use <<tag-picker tagField:foo>> I get an edit box and ‘add’ button as expected, but when I choose tags, they are not added to the edit box. If I edit the tiddler I see they are added to the field. Also, if I create new tags they are not added to the picker list
How can I make it work as expected? In my case, I want the chosen tags to be added to the field and any new one to become part of what the picker shows, and it can be via adding it to the list of tags in the wiki
And while I’m asking, how can I list a tiddler’s tags in a list of tiddlers (e.g. next to each tiddler’s title)
The contents of the tag input dropdown list should be configurable, and for backward-compatibility should still default to showing a list of tag values, regardless of the target tagField parameter value. This can be achieved with just a few small changes to the existing $:/core/macros/tag-picker definition:
In the main tag-picker macro definition, change
\define tag-picker(actions,tagField:"tags")
to \define tag-picker(actions,tagField:"tags",tagFilter:"[tags[]]")
<$vars saveTiddler=<<currentTiddler>> palette={{$:/palette}}>
to <$vars saveTiddler=<<currentTiddler>> palette={{$:/palette}} tagFilter=<<__tagFilter__>>>
Then, in the tag-picker-inner macro definition, change
nonSystemTagsFilter="[tags[]!is[system]search:title<userInput>sort[]]"
to nonSystemTagsFilter="[subfilter<tagFilter>!is[system]search:title<userInput>sort[]]"
systemTagsFilter="[tags[]is[system]search:title<userInput>sort[]]"
to systemTagsFilter="[subfilter<tagFilter>is[system]search:title<userInput>sort[]]"
Also, change field first-search-filter from
[tags[]!is[system]search:title<userInput>sort[]]
to [subfilter<tagFilter>!is[system]search:title<userInput>sort[]]
and change field second-search-filter from
[tags[]is[system]search:title<userInput>sort[]]
to [subfilter<tagFilter>is[system]search:title<userInput>sort[]]
Thank you! When I change this macro, what happens when I upgrade TW5? Will the changes be gone, do I need to remember I overwrote the shadow tiddler and sometime revert?
If I want to have these changes as part of a plugin, how do I go about doing that? That is, do I change the shadow macro and then export as part of the plugin package, or is there another mechanism where a tiddler in a plugin package overwrites a a core shadow tiddler? Something where if I disable the plugin, the changes no longer apply.
When you modify a shadow tiddler, it becomes a “real” tiddler, and overrides the shadow definition. When you upgrade the TWCore, the “real” tiddler will continue to override the shadow, even if the upgraded TWCore contains a newer version of the shadow tiddler.
Note that the changes I have outlined are 100% backward-compatible with the current TWCore shadow macro definition, so unless the TWCore adds new functionality to the macro, you can safely rely upon your modified macro to continue to perform properly even after upgrading the TWCore.
Regardless, if you want the TWCore shadow tiddler definition to be re-applied, you can either:
A) delete the modified tiddler,
or
B) rename the modified tiddler AND remove the $:/tags/Macro tag from it.
@EricShulman this or perhaps a generic tiddler-picker for list fields is a missing feature in the core and worthy of a submission.
Although I have versions of the Link view/editor toolbar buttons that do this
I have cloned the current $:/core/macros/tag-picker, made the changes you suggested and removed the unchanged macros, so a separate tiddler can be maintained. leaving the core tiddler intact.
As long as this new one is defined after that in the tag $:/tags/Macro it will win over the core.
Thanks very much for doing this work @EricShulman I was about to do it myself.
I also created a new one with the name tiddler-picker with different parameter names and order \define tiddler-picker(fieldname:"tags",filter:"[tags[]]",actions)
But the placeholder and tooltips are incorrect
Next the ability to trigger equivalent tag pills may be nice but I think GenTags does this already.
The tag-picker input field is only intended for entering a new value to add to the tagField, one value at a time, and does not display the current list of all assigned values. To display the current values stored in the foo field (similar to how the tag-picker works when editing a tiddler), you can write something like this:
Thanks, can you help with one final mystery I have? I need to use the tags in the field (foo above) plus another one as parameter to a widget attribute.
I tried $tags={{{ anothertag [enlist{!!foo}}] +[join[ ]] }}} but while the field will contain tag names with spaces as [[tag with space]], when i look a the attribute passed to the widget, the square brackets are gone. I also tried $tags={{{ anothertag [get[foo]] +[join[ ]] }}} but this seems to duplicate the field value
I needs something so that in the widget I can take the attribute value and put it as-is to the tags field of a tiddler I’m creating.
Since the value of the foo field is already a properly formatted list (i.e., with doubled square brackets around values that contain spaces), you just need to join “anothertag” onto it (separated by a space, of course).
Thus:
$tags={{{ anothertag [{!!foo}] +[join[ ]] }}}
Note also that in your posted syntax, ...[enlist{!!foo}}]..., you had an extra closing }.
For the <<tag-picker>> macro, this could be addressed in tag-picker-inner() by appending the tagField parameter value to the state tiddler title, like this:
First, construct the state tiddler title and store it in a variable (e.g., popid):
@EricShulman if I used the same tag picker macro on the same current tiddler inside the same tiddler (not likely but possible) will we still have a problem?
What if popid is set outside the tag picker macro when needed?
Since the calculated popid value includes a [<qualify>] value, you can force different qualify values by wrapping the <<tag-picker>> calls within `<$let transclusion=“something”>, like this: