Creating a new tiddler template

2,642 views
Skip to first unread message

Kashgarinn

unread,
Dec 31, 2007, 7:21:48 AM12/31/07
to TiddlyWiki
Hi there.

I'm creating a procedure we can follow for each evening at work, and I
keep that in "nightshift procedure" tiddler.

What I want is a button instead of the new journal button which is
called "new nightshift" and it basically creates a new journal with a
few twists.

1) It adds the "nightshift" tag to it
2) adds all the content from the "nightshift procedure" tiddler into
the new journal tiddler
3) if possible, doesn't open it so you go into edit mode, just creates
a new tiddler and displays it.

I would be interested in not actually keeping the info in the tiddler,
as the whole thing is pretty static, and all I really want is the log
that the journal was created and by whom, I don't really need to bloat
it with excessive copies of what's in the "nightshift procedure"
tiddler.

I'd love to do it in a spiffy way to minimise clutter and having the
same data over and over again.

I've no idea how to do it, been trying to research it but can't seem
to do it properly. Any suggestions?

wolfgang

unread,
Dec 31, 2007, 8:15:41 AM12/31/07
to TiddlyWiki
Hi Kashgarinn,

Take a look at the NewSavedTiddler.js Saq posted in the following
thread:

http://groups.google.com/group/TiddlyWiki/browse_thread/thread/3098a7a55b72a6aa/bed6e9ec66bbc366?lnk=gst&q=newTiddlerWithForm+tags#bed6e9ec66bbc366

With this macro installed you're able to create a new tiddler while
having it opened in view mode.

For adding a tag and a custom text - the new tiddler's macro with
parameter would to. And for not having the same long text included I
would just use the <<tiddler TiddlerTite>> macro in each.

Regards,

W.

FND

unread,
Dec 31, 2007, 9:08:03 AM12/31/07
to Tiddl...@googlegroups.com
> For adding a tag and a custom text - the new tiddler's macro with
> parameter would to. And for not having the same long text included I
> would just use the <<tiddler TiddlerTite>> macro in each.

Wolfgang has already summarized everything you need - though of course
you could also use the NewJournal macro instead of NewTiddler:
http://tiddlywiki.com/#NewJournalMacro%20NewTiddlerMacro

Just one minor catch: Embedding macro calls into a macro parameter can
be tricky.
So here's a workaround (not using NewSavedTiddler yet though):
<<newJournal
"YYYY-0MM-0DD (week WW)"
label:"new nightshift"
prompt:"create a new nightshift tiddler"
text:{{"<<tiddler [[Nightshift Procedure]]>" + ">"}}
tag:"nightshift"
>>
What's important here is the {{evaluated}} "text:" parameter - I've
separated the two ">" characters to prevent TiddlyWiki from thinking
that the original (NewJournal) macro ends there.
I have also added a custom date format* and a prompt/tooltip, both of
which are optional.

HTH.


-- F.


* cf. http://www.tiddlywiki.org/wiki/Timestamps

Eric Shulman

unread,
Dec 31, 2007, 9:17:20 AM12/31/07
to TiddlyWiki
> text:{{"<<tiddler [[Nightshift Procedure]]>" + ">"}}

> What's important here is the {{evaluated}} "text:" parameter - I've
> separated the two ">" characters to prevent TiddlyWiki from thinking
> that the original (NewJournal) macro ends there.

you can also write it like this:

text:{{"<<tiddler [[Nightshift Procedure]]>\>"}}

-e


Kashgarinn

unread,
Jan 2, 2008, 4:20:36 AM1/2/08
to TiddlyWiki
Thanks alot for your replies, they worked great.

I was wondering how I could tag the tiddler with the number of the
week, or the today date, is that possible?

Regards,
K.

wolfgang

unread,
Jan 2, 2008, 4:25:48 AM1/2/08
to TiddlyWiki
I think AutoTaggerPlugin does that.

http://www.tiddlytools.com/#AutoTaggerPlugin

Regards,

W.

Kashgarinn

unread,
Jan 2, 2008, 4:25:58 AM1/2/08
to TiddlyWiki
I was a bit too quick.. Just tested whether the newly created
nightshift tiddler would overwrite an already created tiddler, and it
seems that it does.. Is it because I'm using the new journal macro?

FND

unread,
Jan 2, 2008, 7:44:42 AM1/2/08
to TiddlyWiki
> Just tested whether the newly created nightshift tiddler would
> overwrite an already created tiddler, and it seems that it does.

If the NewJournal (or NewTiddler) macro encounters an already-existing
tiddler of the same name, it should open that tiddler in edit mode
(not overwrite it).
Also, since we're using a date for the newly-created tiddler's title,
that title should almost always be unique.
Could you elaborate on what's happening on your end?

> you can also [escape the embedded macro] like this:
> text:{{"<<tiddler [[Nightshift Procedure]]>\>"}}

Thanks, Eric, I had forgotten about this (simpler) method.


-- F.

Eric Shulman

unread,
Jan 2, 2008, 7:57:39 AM1/2/08
to TiddlyWiki
> Also, since we're using a date for the newly-created tiddler's title,
> that title should almost always be unique.

Unless, of course, you invoke "new nightshift tiddler" more than once
on the same day! If you really need to always have a new journal
tiddler created, you can add a timestamp to the tiddler title, like
this:

<<newJournal "MM/DD/YYYY 0hh:0mm" ...>>

-e

FND

unread,
Jan 2, 2008, 8:14:10 AM1/2/08
to TiddlyWiki
> I would be interested in not actually keeping the info in the tiddler,
> as the whole thing is pretty static

Just in case:
You might be interested in "transclusion" to fill placeholder values
in the [[Nightshift Procedure]] tiddler.
Basically, your [[Nightshift Procedure]] tiddler template would look
like this:
|!Staffer|$1|
|!Time|$2|
Lorem ipsum dolor sit amet ...
Then your macro call might look like this:
---------------
<<newJournal
"YYYY-0MM-0DD (week WW)"
label:"new nightshift"
prompt:"create a new nightshift tiddler"
text:{{"<<tiddler [[Nightshift Procedure]] with:"
+ '"' + config.options.txtUserName + '" '
+ '"' + (new Date).formatString("YYYY-MM0-DD0 0hh:0mm") + '"'
+ ">\>"
}}
tag:"nightshift"
>>
---------------
This would automatically insert the current username and timestamp.

More information on parametric transclusion here:
http://www.tiddlywiki.org/wiki/Transclusion#Parametric_Transclusion
(Okay, there's just a link for now, but some day... )

HTH.


-- F.

Eric Shulman

unread,
Jan 2, 2008, 9:03:10 AM1/2/08
to TiddlyWiki
> I'm creating a procedure we can follow for each evening at work, and I
> keep that in "nightshift procedure" tiddler.
> as the whole thing is pretty static, and all I really want is the log
> that the journal was created and by whom, I don't really need to bloat
> it with excessive copies of what's in the "nightshift procedure"
> tiddler.

Seems to me that you don't need to create a separate "journal" tiddler
each and every time someone follows the nightshift procedure. You
really just want to record *when* the procedure was performed, and *by
whom*... plus, perhaps, a brief comment from that person, reporting
any problems or notes that result from that procedure.

As an alternative to your "New Journal" strategy, you might consider
using:
http://www.TiddlyTools.com/#CommentScript

1) Create a tiddler called [[NightshiftProcedures]] containing the
*static* text of the nightshift procedure instructions

2) Create a tiddler called [[NightshiftLog]] containing:
<<tiddler CommentScript>>
/%comment%/

3) Add a link to [[NightshiftLog]] in your menu (or wherever you
like).

To use: click the NightshiftLog link. Click "add a note". You don't
have to enter anything... not even the subject text. Then click
"post": a new note, including a timestamp and username, will be
automatically added to the NightshiftLog tiddler.

You can customize the format of the comment by redefining:
config.options.txtCommentFormat="format string"
(put this in a [[CookieJar]] systemConfig tiddler)

The default format string is:
"+++!!!!![%0 (%1): %2]>\n%3===\n"
where: %0=date/timestamp, %1=username, %2=subject, and %3 is the body
of the comment.

Note that this uses the NestedSlidersPlugin syntax to create headings
for 'collapsible' notes. If you don't want/need this ability, you can
simplify the format to:
"%0 (%1): %2\n%3\n"
and, for your purposes (if the subject and comments are not needed),
you could simply use:
"%0 (%1): Nightshift procedures performed\n"

HTH,
-e
Eric Shulman
TiddlyTools / ELS Design Studios

Eric Shulman

unread,
Jan 2, 2008, 9:06:30 AM1/2/08
to TiddlyWiki
errata:

You probably also want to include the [[NightshiftProcedures]] content
in the log, so that people can actually *read* the nightshift
instructions... Thus:

2) Create a tiddler called [[NightshiftLog]] containing:
<<tiddler NightshiftProcedures>>
<<tiddler CommentScript>>
/%comment%/

-e

Kashgarinn

unread,
Jan 2, 2008, 9:52:08 AM1/2/08
to TiddlyWiki
Hey there and thanks for your replies :)

I'm actually very happy with how the tiddler macro already displays
the "nightshift procedure" tiddler, so I'm fine with adding that line
to all the journal logs.
this is the command I came up with in sidebaroptions:

<<newJournal
"DD MMM YYYY"
label:"nýtt Kvöldferli"
prompt:"create a new nightshift tiddler"
text:{{"<<tiddler [[Kvöldferlið]]>" + ">" + " [_(|Búið)] Allt ferlið
lokið?"}}
tag:"Kvöldferli"
>>

This both adds the procedure as an instance, and adds a checkmark
which will tag the tiddler "done" (or "búið") - I'd really just like
to add that clicking the checkbox also saves the TW as I'm using CCTW
and need to manually save after checking the box.

if you already have a journal tiddler with the name, it will override
it when pushing the "new nightshift" button, which is a shame.. no
idea why. I'd like to minimise ppl being able to screw things up :P

Basically what's happening is that I click the button, and a new
tiddler with all the info opens up in edit mode. I click done, and
voila it's like I want it. For testing purposes, I add below the
checkmark "Testing" and click done again.
I close and refresh the TW, and the tiddler is still there and
everything works fine. Then I click the "new nightshift" button
again, and a completely new tiddler named the same is created as if
the old one doesn't exist, if I click cancel, then I don't override,
if I click done, I override.

it's a strange problem to be sure

K.

Eric Shulman

unread,
Jan 2, 2008, 10:26:07 AM1/2/08
to TiddlyWiki
> This both adds the procedure as an instance, and adds a checkmark
> which will tag the tiddler "done" (or "búið") - I'd really just like
> to add that clicking the checkbox also saves the TW as I'm using CCTW
> and need to manually save after checking the box.

Did you try my update to CheckboxPlugin, yet? *IF* you can invoke the
CCTW save processing via a javascript function, then you can define an
'onClickAfter' handler for the checkbox, so that checking "done" (and
setting the tag) also saves the file to CCTW.

> if you already have a journal tiddler with the name, it will override
> it when pushing the "new nightshift" button, which is a shame.. no
> idea why. I'd like to minimise ppl being able to screw things up :P

This is because you are using the "text:..." param in
<<newJournal ...>> If the tiddler exists and you DON'T specify default
text in the macro, then the current tiddler contents are used. But
when you specify the default text in the macro, that value overrides
any previously-stored content... which is, IMO, as it should be.
After all, the macro is <<NEWJournal>> not <<NEWorEDITJournal>>

One possible (though ugly) way out of this is to write:

text:{{store.getTiddlerText(new Date().formatString("DD MMM
YYYY"),"<<tiddler [[Kvöldferlið]]>\> [_(|Búið)] Allt ferlið
lokið?")}}

(note: google groups adds newlines that mess up the code above... the
"text:" param should be on one line...)

What this does is retrieve the current day's journal contents if it
exists, otherwise it uses the static default definition specified in
the macro param.

One little problem with this method: the text param value is computed
when the macro is rendered... not when it is clicked. Thus, after
creating a new journal, you MUST make sure that the "nýtt Kvöldferli"
command item is refreshed in order for it to re-retrieve the current
journal contents and compute a new default text value. Otherwise, it
will still apply the previously computed default when it is clicked
again.

You can force this command to be refreshed by placing it in an area of
the page that is already being auto-refreshed after EVERY tiddler
change, such as SideBarTabs, or by editing the [[PageTemplate]] to
add:
refresh='content' force='true'
to some other page element, as in:

<div id='mainMenu' refresh='content' force='true'
tiddler='MainMenu'></div>

If you combine all this little bits together, you *should* achieve the
results you are seeking...

HTH,
-e
Reply all
Reply to author
Forward
0 new messages