Button to create tiddler with title and time

299 views
Skip to first unread message

Scott Kingery

unread,
Nov 12, 2018, 7:56:16 PM11/12/18
to TiddlyWiki
Given a tiddler called "Tiddler X", I would like to include a button it that would create a new tiddler called "Tiddler X: and the current date time"

This non-working code is an example of what I mean

<$button>New Project
<$action-sendmessage $message="tm-new-tiddler" text='{{||$:/project}}' tags={{!!title}} title={{!!title}} <
<now "YYYY-0MM-0DD hh12:0mmpm">>/>
</$button>

I think I need to build a macro to get the title and time together in some fashion but can't seem to sort it out.

If that can't be done then I'd like auto-increment so the new tiddler would be {{!!title}}+# similar to how you get "New Tiddler 2" if one exists.

Thanks

TonyM

unread,
Nov 12, 2018, 10:41:10 PM11/12/18
to TiddlyWiki
Scott,

Have you looked at the New Journal Button? 

In Control Panel > Info > basics you set the new Title of Journal tiddler, in 

$:/config/NewJournal/Title eg New Tiddler X YYYY-0MM-0DD


On the View Toolbar you can also go new Journal here.

Alternatively take a look at https://tiddlywiki.com/#ActionCreateTiddlerWidget which is another way to create tiddlers. which includes
$basetitleThe initial title that will be attempted. If a tiddler with that title already exists, then a numerical counter is added to the title and incremented until it is unique
$savetitleA text reference identifying a field or index into which the title of the newly created tiddler will be stored after it is created

Finally, title={{!!title}} <<now "YYYY-0MM-0DD hh12:0mmpm">> will only read as title={{!!title}}

I suggest you construct the title with the wikify widget and the now macro before you place it in your action eg
title=<<new-title>>

Regards
Tony

Scott Kingery

unread,
Nov 13, 2018, 9:49:33 AM11/13/18
to TiddlyWiki
Thanks, Tony. Your clues to wikify helped.

I got closer. Now I just have to figure out how to concatenate the 2 fields.

<$wikify name=mytime text=<<now "YYYY-0MM-0DD hh12:0mmpm">> >
<$wikify name=mytitle text={{!!title}} >
<$button>New Project
<$action-sendmessage $message="tm-new-tiddler" tags={{!!title}} title=<
<mytime>>/>
</$button>
</$wikify></$wikify>

Scott Kingery

unread,
Nov 13, 2018, 2:36:44 PM11/13/18
to TiddlyWiki
A bit more poking and prodding and I've go it:

\define concatenate() {{!!title}}: <<now "YYYY-0MM-0DD hh12:0mmpm">>


<$wikify name="newtitle" text=<<concatenate>> >
<$button>New Project
<$action-sendmessage $message="tm-new-tiddler" tags={{!!title}} title=<<newtitle>>/>
</
$button>
</$wikify>

Create a new tiddler from the current one using the current one's name and the datetime. Also tags it with the current title. Sounds odd but it makes sense for my current project :)

TonyM

unread,
Nov 13, 2018, 5:23:23 PM11/13/18
to TiddlyWiki
Scott,

Glad you worked through it. The following would wor, saving some steps, 

<$wikify name="newtitle" text="""{{!!title}}: <<now "YYYY-0MM-0DD hh12:0mmpm">>""">

You can load quite a bit into the wikify and using the three quotes """ ensures the content can contain "

Regards
Tony

Mohammad

unread,
Nov 13, 2018, 11:10:41 PM11/13/18
to tiddl...@googlegroups.com
There is one issue!
When your title has space, then the tags={{!title}} would not work as expected!

Check it

Mohammad

Scott Kingery

unread,
Nov 14, 2018, 12:22:43 AM11/14/18
to tiddl...@googlegroups.com
Yeah, thanks Mohammad  . Found out about the spaces issue the hard way. Still thinking it though. Might store the value in a field instead.

On Tue, Nov 13, 2018 at 8:10 PM Mohammad <mohammad...@gmail.com> wrote:
There is one issue!
When you title has space, then the tags={{!title}} would not work as expected!

Check it

Mohammad

--
You received this message because you are subscribed to a topic in the Google Groups "TiddlyWiki" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/tiddlywiki/nC5RtR1L01M/unsubscribe.
To unsubscribe from this group and all its topics, send an email to tiddlywiki+...@googlegroups.com.
To post to this group, send email to tiddl...@googlegroups.com.
Visit this group at https://groups.google.com/group/tiddlywiki.
To view this discussion on the web visit https://groups.google.com/d/msgid/tiddlywiki/b5bc185f-cc52-4a18-ba34-d5ff3ad3a62f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Mohammad

unread,
Nov 14, 2018, 1:35:58 PM11/14/18
to TiddlyWiki
Hello Scott,

Check this

Create a tiddler, name it what you like. Tag it with $:/tags/Macro
\define newTid(param:"", btn-caption:"New project", color:"#8058A5") 
<$button style="color:$color$; fill:$color$; margin-bottom:5px;">
{{$:/core/images/new-button}} $btn-caption$

<$wikify name="newTitle" text="""{{!!title}}: <<now "YYYY-0MM-0DD hh12:0mmpm">>""">
<$action-sendmessage $message="tm-new-tiddler"
    title=<<newTitle>>
    text="..."
    tags="[[$param$]]"
/>
</$wikify>
</$button>
\end




In any tiddler you like to have the button put the below command

<<newTid param:"$(currentTiddler)$">>


Let me know if it works for you!

Mohammad

Scott Kingery

unread,
Nov 14, 2018, 4:47:55 PM11/14/18
to tiddl...@googlegroups.com
Mohammad,
Yes! Thanks a ton. A few modifications to give it exactly what I wanted to pass to my new tiddler and it works perfectly. You also showed me how to add color to my button :)

--
You received this message because you are subscribed to a topic in the Google Groups "TiddlyWiki" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/tiddlywiki/nC5RtR1L01M/unsubscribe.
To unsubscribe from this group and all its topics, send an email to tiddlywiki+...@googlegroups.com.
To post to this group, send email to tiddl...@googlegroups.com.
Visit this group at https://groups.google.com/group/tiddlywiki.
Reply all
Reply to author
Forward
0 new messages