So, I've tried using plain old <<newTiddler...> with the syntax
<<newTiddler template:ViewTemplate text:"<<formTiddler
[[StorylineTemplate]]>>" tag:storyline>>
*but* this takes the closing >> in the quoted text as the closing >>
for the newTiddler macro, meaning that the button appears, followed by
'" tag:storyline>>' and it doesn't work. Also, this method cannot be
used to prompt for a tiddler title, the way that newTiddlerWithForm
does.
So, how do I create a new tiddler, with the desired body text and tags
*and* prompt the user for a title for that tiddler?
Many thanks in advance,
David Shaw
Let me start with a quick note:
The NewTiddler macro's "template" parameter might be confusing, as it
refers to a ViewTemplate, not a template in the transclusion[1] sense
(as used by the MediaWiki engine, for example).
Transclusion is achieved with the NewTiddler macro.
Take a look at this:
http://www.tiddlywiki.org/wiki/Preloading
If you have a tiddler with the desired formTiddler macro, you could
transclude that into your newly-created tiddler, circumventing the issue
of embedded "<<" and ">>" chars.
That leaves us with the prompt; for that, you will need a tiny bit of
embedded JavaScript code. But there's an issue with that:
Theoretically, resulting button would be created with something like the
following macro code:
<<newTiddler label:"new record"
title:{{prompt("Please enter a title.");}}
text:{{store.getTiddlerText("foo")}}
tag:"bar">>
(Note: "foo" and "bar" are to be replaced by the tiddler and tag of your
choice. Also, while this has not been extensively tested, I guess it
*should* work... )
However, with that code, the prompt will not appear when pressing the
macro button, but rather when the respective tiddler is opened.
There's probably a solution to that - most likely involving Eric's
InlineJavascriptPlugin[2] - but I'm afraid don't have one to offer
right now...
HTH.
-- F.
[1] Transclusion, here, means including the contents of one tiddler in
another tiddler; cf. http://en.wikipedia.org/wiki/Transclusion
Many thanks for your quick response - unfortunately, I cannot get it to
work as I want :-(
I don't want the tiddler to appear in edit mode - rather, I want it to
appear in view mode, so that the form appears, ready for people to edit
the form, rather than the tiddler (does that make sense?), so I tried
the following as the template for a FormTiddler
<html>
<sub><b>Title:</b></sub><br/><input name=title type=text/>
</html>
<<newTiddler label:"Create new storyline"
template:ViewTemplate
title:{{store.getTiddler("Storylines").data("title")}}
text:{{store.getTiddlerText("StoryTemplate")}}
tag:"storyline">>
but when I click on the button, it just gives me a tiddler with 'The
tiddler (title) doesn't yet exist' *and* the title won't actually
initialise until the second click of the button - *and* I need to close
down the tiddler and reopen it if I want to change the title to create
another new tiddler.
Anyway, thank you for your help - I guess I shall just have to file yet
another problem in the 'when I know enough JavaScript' category :-)
David Shaw
Many, many thanks, Saq - that does the job beautifully :-)
David