[TW5] Tag Pill by another name?

186 views
Skip to first unread message

TonyM

unread,
Nov 13, 2017, 7:15:27 PM11/13/17
to TiddlyWiki

Folks,

A Small request, I could not solve.

As you know {{||$:/core/ui/TagTemplate}} displays a Tag Pill for the current tiddler.

Does anyone know a way to retain all the functionality of a tag pill, ie colour, dropdown list of tagged tiddlers (open all tiddlers provided by plugin)

However allowing me to provide a different name eg "Tagging" rather than the current tiddlers name?

Thanks in advance
Tony



Diego Mesa

unread,
Nov 13, 2017, 8:35:20 PM11/13/17
to TiddlyWiki
Hm, 

I thought something like this would work:

{{!!alt-title||$:/core/ui/TagTemplate}}

but that also just shows the current tiddlers name. 

Eric Shulman

unread,
Nov 13, 2017, 8:41:24 PM11/13/17
to TiddlyWiki
On Monday, November 13, 2017 at 4:15:27 PM UTC-8, TonyM wrote:
As you know {{||$:/core/ui/TagTemplate}} displays a Tag Pill for the current tiddler.
Does anyone know a way to retain all the functionality of a tag pill, ie colour, dropdown list of tagged tiddlers (open all tiddlers provided by plugin)
However allowing me to provide a different name eg "Tagging" rather than the current tiddlers name?

You can modify the $:/core/macros/tag shadow tiddler definition.  In the tag-pill-inner definition, find this part:
<$view tiddler="""$tag$""" field="title" format="text"/>

and change it to this:
<$view tiddler="""$tag$""" field="tagtitle" format="text"><$view tiddler="""$tag$""" field="title" format="text"/></$view>

Then, to override the default tag pill text (i.e., the title text), add a field named "tagtitle" to the tag definition, and it will use that text as the alternative to the tag tiddler's title text.

enjoy,
-e
Eric Shulman
TiddlyTools.com: "Small Tools for Big Ideas" (tm)
InsideTiddlyWiki: The Missing Manuals

TonyM

unread,
Nov 13, 2017, 9:20:17 PM11/13/17
to TiddlyWiki
Eric,

That is an interesting solution, and I may use it in different circumstances. It suites my interest in simplifying customisations even more.

On this Occasion I want to to display a fixed value for all tiddlers that are tagged with another, I should explain myself.

I want to create a Tagpill perhaps called "Tagging" which displays next to the tiddler header which looks the same for every tiddler. A Consistent name to  look for, such that I can click on it and open any of the tiddlers tagged by this one, or for which this one is Tagging.

Some tiddlers titles are too long to repeat their name in a such a tagpill. It will then work like an old TWC tool that gave every tiddler a dropdown to see what it tags,

It will also help my development workflow by letting me drag the set of tiddlers so tagged to other wikis (without having to use the open tab in the sidebar, to find a dragable link).

In addition It will only show this if the tiddler has any tags, allowing me to identify at a glance if a given tiddler tags anything else.

Finally, If I can I would like to add a filter that would allow me to show for example the tiddler is tagged with the current tiddler name AND the tag "Active".

I looked to copying and reworking $:/core/ui/TagTemplate but realised I could not fully understand it.

Regards
Tony

Jed Carty

unread,
Nov 14, 2017, 4:43:28 AM11/14/17
to TiddlyWiki
The tag macro does exactly that.


<<tag foo>>

will display the tag pill foo with all the expected behaviour (dropdown, dragging, etc.)

I think that we may need to do another big overhaul of the documentation.

Jed Carty

unread,
Nov 14, 2017, 4:47:06 AM11/14/17
to TiddlyWiki
Sorry, I think I misunderstood what you are asking. The <<tag foo>> macro is a shorter way to get {{foo||$:/core/ui/TagTemplate}}, but it doesn't give a way to change the label on the tag.

TonyM

unread,
Nov 14, 2017, 6:17:34 AM11/14/17
to TiddlyWiki
Jed,

Yes, that seems to be the challenge.

I found the tag system macro in, 

$:/core/macros/tag 

but it uses the transclusion as well.

There is a tag-pill macro with no examples, but it seems to resort to a transclusion as well.


Tony

Jed Carty

unread,
Nov 14, 2017, 8:55:49 AM11/14/17
to TiddlyWiki
I think that this is worth making something for so I will try and make an alternate version of the tag template that lets you put in a different label when I get home. Hopefully it won't take too long.

Jed Carty

unread,
Nov 14, 2017, 9:28:07 AM11/14/17
to TiddlyWiki
This replaces the tag macro with something that is backwards compatible so it won't break anything, but if you give a second input to the tag macro it will display that instead of the tag title.

So <<tag foo bar>> will display a tag pill that says 'bar' but otherwise it will act like the tag pill for foo. It is backwards compatible so it doesn't break anything in how tags normally act. It is a bit hacky for the moment since we don't have a good way to test for an empty variable.

Put this into a tiddler tagged with $:/tags/Macro (or replace the contents of $:/core/macros/tag with this):

\define tag-pill-styles()
background-color:$(backgroundColor)$;
fill:$(foregroundColor)$;
color:$(foregroundColor)$;
\end

\define tag-pill-inner(tag,icon,colour,fallbackTarget,colourA,colourB,element-tag,element-attributes,actions)
<$vars foregroundColor=<<contrastcolour target:"""$colour$""" fallbackTarget:"""$fallbackTarget$""" colourA:"""$colourA$""" colourB:"""$colourB$""">> backgroundColor="""$colour$""">
<$element-tag$ $element-attributes$ class="tc-tag-label tc-btn-invisible" style=<<tag-pill-styles>>>
$actions$<$transclude tiddler="""$icon$"""/> <$list filter='[{$:/core/macros/tag!!someemptyfield2}!prefix<LABEL>]' emptyMessage='<$view tiddler="""$tag$""" field="title" format="text" />' variable='dummy'><<LABEL>></$list>
</$element-tag$>
</$vars>
\end

\define tag-pill-body(tag,icon,colour,palette,element-tag,element-attributes,actions)
<$macrocall $name="tag-pill-inner" tag="""$tag$""" icon="""$icon$""" colour="""$colour$""" fallbackTarget={{$palette$##tag-background}} colourA={{$palette$##foreground}} colourB={{$palette$##background}} element-tag="""$element-tag$""" element-attributes="""$element-attributes$""" actions="""$actions$"""/>
\end

\define tag-pill(tag,element-tag:"span",element-attributes:"",actions:"")
<span class="tc-tag-list-item">
<$macrocall $name="tag-pill-body" tag="""$tag$""" icon={{$tag$!!icon}} colour={{$tag$!!color}} palette={{$:/palette}} element-tag="""$element-tag$""" element-attributes="""$element-attributes$""" actions="""$actions$"""/>
</span>
\end

\define tagLabel(tag label)
<$set name=LABEL value="""$label$""">
{{$tag$||$:/core/ui/TagTemplate}}
</$set>
\end

PMario

unread,
Nov 15, 2017, 7:48:51 AM11/15/17
to TiddlyWiki
On Tuesday, November 14, 2017 at 3:20:17 AM UTC+1, TonyM wrote:
Some tiddlers titles are too long to repeat their name in a such a tagpill. It will then work like an old TWC tool that gave every tiddler a dropdown to see what it tags,

You can enable the tiddler info section and have a look at the tagging tab.

-m

TonyM

unread,
Nov 15, 2017, 7:55:17 AM11/15/17
to TiddlyWiki
Jed,

A Quick go did not work for me, But I will look at it as soon as I finish some other work, migrating an online shop.

I am glad you see the value in my suggestion and put some work into it. Thanks

Regards
Tony
 

Jed Carty

unread,
Nov 15, 2017, 8:07:23 AM11/15/17
to TiddlyWiki
Sorry, I copied the wrong thing into the post. The macro at the end was named tagLabel instead of just tag. Here is the fixed version, it just has the marco name changed:


\define tag-pill-styles()
background-color:$(backgroundColor)$;
fill:$(foregroundColor)$;
color:$(foregroundColor)$;
\end

\define tag-pill-inner(tag,icon,colour,fallbackTarget,colourA,colourB,element-tag,element-attributes,actions)
<$vars foregroundColor=<<contrastcolour target:"""$colour$""" fallbackTarget:"""$fallbackTarget$""" colourA:"""$colourA$""" colourB:"""$colourB$""">> backgroundColor="""$colour$""">
<$element-tag$ $element-attributes$ class="tc-tag-label tc-btn-invisible" style=<<tag-pill-styles>>>
$actions$<$transclude tiddler="""$icon$"""/> <$list filter='[{$:/core/macros/tag!!someemptyfield2}!prefix<LABEL>]' emptyMessage='<$view tiddler="""$tag$""" field="title" format="text" />' variable='dummy'><<LABEL>></$list>
</$element-tag$>
</$vars>
\end

\define tag-pill-body(tag,icon,colour,palette,element-tag,element-attributes,actions)
<$macrocall $name="tag-pill-inner" tag="""$tag$""" icon="""$icon$""" colour="""$colour$""" fallbackTarget={{$palette$##tag-background}} colourA={{$palette$##foreground}} colourB={{$palette$##background}} element-tag="""$element-tag$""" element-attributes="""$element-attributes$""" actions="""$actions$"""/>
\end

\define tag-pill(tag,element-tag:"span",element-attributes:"",actions:"")
<span class="tc-tag-list-item">
<$macrocall $name="tag-pill-body" tag="""$tag$""" icon={{$tag$!!icon}} colour={{$tag$!!color}} palette={{$:/palette}} element-tag="""$element-tag$""" element-attributes="""$element-attributes$""" actions="""$actions$"""/>
</span>
\end

\define tag(tag label)

TonyM

unread,
Nov 15, 2017, 4:32:42 PM11/15/17
to TiddlyWiki
Thanks Jed,

That works very well, I think I will get it to float right of the current tags in the view template. Wrapped to show only if there is a tiddler tagged with the current tiddlers title. 

<$list filter="[all[current]tagging[]limit[1]]" variable=null >
<<tag Here>>
</$list>

  • Its great that the tag color comes through
  • Tag pils can be presented with a fixed length despite underlying name, allowing smarter presentation

However I also see other uses. I have a set of tags which have a suffix eg action-wip action-done, with action or task as examples of the prefix.

It is now possible to provide a tag pill for wip and done irrespective of what the prefix is, 

Thanks for stepping int to help.
I see real value having this in the core.

Regards
Tony
Reply all
Reply to author
Forward
0 new messages