new tiddler with tag button

96 views
Skip to first unread message

Ed Heil

unread,
Mar 19, 2020, 2:49:04 PM3/19/20
to tiddl...@googlegroups.com
Something I find myself doing often, when I have a tiddler that lists other tiddlers with a tag, is create a button which makes a new tiddler with that tag pre-populated. For example, on a page that lists tickets, a button that makes new tickets.

The way I usually do that is with an action message widget, so that I can do something like this:

> <$button>New Ticket
> <$action-sendmessage $message="tm-new-tiddler" title="New Ticket" tags="ticket" />
> </$button>

But it'd be nice if I could tuck all that into the button tag instead of needing a separate action-sendmessage tag. But all I can do inside a button is pass one parameter to the tm-new-tiddler message, and that must be a name of a template.

That's cool, I can make a NewTicketTemplate with that tag already added! But wait, if I do that, that template is going to show up every time I list tickets unless I explicity exclude it. That's a way bigger drag than having to do the action-sendmessage.

I'm just wondering, have I correctly assessed my options, or is there an easier still way to do this?

Obviously I can make the whole problem (which isn't much of a problem) go away with a macro, I'm just wondering if I'm missing some clever tiddlywiki-fu that would make the template idea work better.

Thanks,

Ed

Mat

unread,
Mar 19, 2020, 3:05:54 PM3/19/20
to TiddlyWiki
Ed Heil wrote:
That's cool, I can make a NewTicketTemplate with that tag already added!  But wait, if I do that, that template is going to show up every time I list tickets unless I explicity exclude it.

There are some fundamental presumptions in what you describe that I don't get. What do you mean with a "template showing up"? Do you mean the button? Are you talking about a ViewTemplate or what template? And why does it sound like you make the button merely to temporarily make a list appear?

<:-)
 

Ed Heil

unread,
Mar 19, 2020, 10:51:01 PM3/19/20
to TiddlyWiki
I probably explained poorly!  It made sense in my head at the time.

OK, look at the example for the tm-new-tiddler message:


To make a button that creates new tiddlers tagged "task", create a tiddler called "TaskTemplate" with that tag, and then make your button like this:
<$button message="tm-new-tiddler" param="TaskTemplate">New Task</$button>

Why would you want to do that?  If you have a tiddler named TaskTemplate it's always going to show up whenever you filter on tasks ([tag[task]]) unless you explicitly filter it out ([tag[task]![TaskTemplate]]). Seems like a bad way to go.

So I always use a button with an actual ActionSendWidget inside it so I can have it set the tag at creation time.

I'm wondering if I'm missing some way you could use a template without running across that inconvenience, of the template showing up whenever you were looking for the actual thing it's a template for.

Does that make any sense?

If not, no worries -- it is kind of a trivial matter.

Mat

unread,
Mar 20, 2020, 12:25:00 AM3/20/20
to TiddlyWiki
Ed Heil wrote:

To make a button that creates new tiddlers tagged "task", create a tiddler called "TaskTemplate" with that tag, and then make your button like this:
<$button message="tm-new-tiddler" param="TaskTemplate">New Task</$button>

Why would you want to do that?  If you have a tiddler named TaskTemplate it's always going to show up whenever you filter on tasks ([tag[task]])

No it won't, unless you tag it "task" which there is no reason to do... unless it's a task... which you indicate that it is not. If you feel a need to tag it, maybe "template" is better. Or maybe I still misunderstand you.

<:-) 

Ed Heil

unread,
Mar 20, 2020, 8:31:54 AM3/20/20
to tiddl...@googlegroups.com
Well, I'm going by the example in the official docs, in which the template has the desired tag already.  I'm pointing out that that example would have undesired consequences, and wondering if there is something about it I'm missing, because to avoid those undesired consequences, you have to do something slightly more complicated than the example.

"It's just an example, and for the reasons you give, you might not want to actually do it that way" is an acceptable answer, if that is the case. :)

-- 
  Ed Heil

Mat

unread,
Mar 20, 2020, 3:14:49 PM3/20/20
to TiddlyWiki
Ed, turns out you're right; the example does propose tagging the template with a particular tag. Instead what you do is this:

<$button>
<$action-sendmessage $message="tm-new-tiddler" $param="TaskTemplate" tags="mytag"/>
New Tiddler
</$button>


<:-)

Ed Heil

unread,
Mar 20, 2020, 3:24:44 PM3/20/20
to tiddl...@googlegroups.com
Yeah, that seems like the best way to go.  Great, thank you, that's what I suspected all along, but the example made me wonder!

-- 
  Ed Heil
Reply all
Reply to author
Forward
0 new messages