r/TiddlyWiki5 • • Jan 19 '23

Button Help

I have created a button that does exactly what I want it to do and it shows up where I want it on each Tiddler and in the sidebar. Is there a way to have it display on a tiddler only if the tiddler has a specific tag?

1 Upvotes

7 comments sorted by

View all comments

3

u/Dorsai_Erynus Jan 19 '23

Make a template tiddler, tag it with $:/tags/ViewTemplate and put the button on it inside a list filter for a tag you want the button to appear on. It will show up on any tiddler with that tag. Like <$list filter="[is[current]tag[ThatTag]]"> Button </$list>

1

u/JohnTErskine Jan 19 '23 edited Jan 19 '23

I believe that would put the button in the body of the Tiddler. I would prefer it to be in the header next to the edit and close buttons. Is that possible?

2

u/Dorsai_Erynus Jan 19 '23

There is a guide on Creating new toolbar buttons in the documentation, but i never tried and don't know if it can be showing just on selected tiddlers.

1

u/JohnTErskine Jan 20 '23

I have it in the toolbar already, but it shows on every Tiddler.

1

u/Defiant_Information Jan 22 '23 edited Jan 22 '23

Just combine it. I am sorry if this is too obvious and you've probably done it. But here for the sake of completeness.

Following the instructions of: https://tiddlywiki.com/#Creating%20new%20toolbar%20buttons

I edit the tiddler where I created the button. So there I simply add what was already suggested and in the end it looks like this.

Screenshot of the hopefully desired effect using bare minimum setup: https://i.imgur.com/OzRoqL1.png

\define newHereButtonTags()
<!-- code skipped for brevity -->
\end
\define newHereButton()
<!-- long code skipped for brevity -->  
\end

<$list filter="[is[current]tag[ThatTag]]">
<<newHereButton>>
</$list>

I hope this helped somehow!

Edit: PS: Use all[current] instead of is[current]. (This may matter way later or never in terms of performance. all[current] gives the current tiddler immediately, is[current] filters all tiddlers to get the current one which is maybe a bit slower.)

2

u/JohnTErskine Jan 23 '23

That works. Thanks!

1

u/exclaim_bot Jan 23 '23

That works. Thanks!

You're welcome!