How to create a newTiddler based on a form that opens in View not Edit mode?

92 views
Skip to first unread message

Rex

unread,
Oct 16, 2007, 1:44:48 AM10/16/07
to TiddlyWiki
I was using the NewTiddlerWithForm macro with Udo's FormTiddlerPlugin
when I came across this thread:
http://groups.google.com/group/TiddlyWiki/browse_thread/thread/3098a7a55b72a6aa/bed6e9ec66bbc366?lnk=gst&q=newTiddlerWithForm+tags#bed6e9ec66bbc366
Now I'm trying to follow the example provided there could use some
help understanding what is being referenced.

Here's the example I'm referring to:
<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">>

And here's my breakdown of what I think I understand, and what I know
I don't understand.

First the text field:
<html>
<sub><b>Title:</b></sub><br/><input name=title type=text/>
</html>
I assume the HTML text box is where you would put the title for the
new tiddler that will be created with the form.

Next:
<<newTiddler label:"Create new storyline" // I understand this is a
label for the newtiddler button

template:ViewTemplate // And I believe this is a call to the
ViewTemplate, as opposed to the EditTemplate which would cause the new
tiddler to open in View mode, which is what I want to have happen.

title:{{store.getTiddler("Storylines").data("title")}} //
This line I don't understand...What are "Storylines" and "title"?

text:{{store.getTiddlerText("StoryTemplate")}} // I think I
understand this line is where you call the form that you want the new
tiddler to be based upon

tag:"storyline">> // and this is the predefined tag

Finally, in order to use Saq's js code that he provided in the thread
referred to above, is that just pasted in as a new tiddler called
NewSavedTiddler and tagged as systemConfig?

~Rex

Morris Gray

unread,
Oct 16, 2007, 2:47:37 AM10/16/07
to TiddlyWiki
On Oct 16, 3:44 pm, Rex <rexwalter...@yahoo.com> wrote:

Finally, in order to use Saq's js code that he provided in the thread
referred to above, is that just pasted in as a new tiddler called
NewSavedTiddler and tagged as systemConfig?

I am interested in doing what your are, but I will have to wait for an
answer too. However I think the javascript creates a button that
implements with this: <<newSavedTiddler>> That will bring up a text
box with the prompt "Create a new saved tiddler" I have now expended
all my knowledge on this subject but it may help you.

Morris Gray
http://twhelp.tiddlyspot.com
A TiddlyWiki help file for beginners

On Oct 16, 3:44 pm, Rex <rexwalter...@yahoo.com> wrote:
> I was using the NewTiddlerWithForm macro with Udo's FormTiddlerPlugin

> when I came across this thread:http://groups.google.com/group/TiddlyWiki/browse_thread/thread/3098a7...

Xavier Vergés

unread,
Oct 16, 2007, 6:17:12 AM10/16/07
to TiddlyWiki
>
> template:ViewTemplate // And I believe this is a call to the
> ViewTemplate, as opposed to the EditTemplate which would cause the new
> tiddler to open in View mode, which is what I want to have happen.

This is the root of the problem: when not using EditTemplate in the
newTiddler macro (*), tags and text are ignored. That's why Saq
created a new macro, <<newSavedTiddler ...>>

(*) This a simplification. According to http://tiddlywiki.com/#NewTiddlerMacro

You can only prime the initial values of fields that map to a text
input box in the specified template (for instance, if you specify the
standard ViewTemplate as the template you won't be able to prime any
fields). For example, this doesn't work as you might expect:
<<newTiddler template:ViewTemplate text:"To be or not to be">>

Rex

unread,
Oct 16, 2007, 10:11:36 AM10/16/07
to TiddlyWiki
Ok, that makes sense to me. So, how does one go about creating a
custom template? I assume it could be as simple as copying the
ViewTemplate code into a new tiddler and giving it a
MyCustomViewTemplate type of a name?

Hmmm... I just tried that and it still didn't work. The macro just
opens a new blank tiddler in view mode, rather than a new tiddler with
my formTiddler Template ready to be filled in.

~Rex

On Oct 16, 5:17 am, Xavier Vergés <xver...@gmail.com> wrote:
> > template:ViewTemplate // And I believe this is a call to the
> > ViewTemplate, as opposed to the EditTemplate which would cause the new
> > tiddler to open in View mode, which is what I want to have happen.
>
> This is the root of the problem: when not using EditTemplate in the
> newTiddler macro (*), tags and text are ignored. That's why Saq
> created a new macro, <<newSavedTiddler ...>>
>

> (*) This a simplification. According tohttp://tiddlywiki.com/#NewTiddlerMacro

Rex

unread,
Oct 16, 2007, 11:43:28 AM10/16/07
to TiddlyWiki
I realized a more detailed explanation of what I have so far would
probably be helpful.

In a tiddler titled "Add OfflineMedia" I've put the following:

<html>
<sub><b>Title:</b></sub><br/><input name=title type=text/>
</html>
<<newTiddler

label:"try this"
prompt:"tooltip"
template:MyCustomViewTemplate
title:{{store.getTiddler("Add OfflineMedia").data("title")}}
text:{{store.getTiddlerText("AddMedia")}}
tag:offlineMedia>>

I also created three other tiddlers that I think are supposed to come
into play: MyCustomViewTemplate, AddMedia and OfflineMediaTemplate

MyCustomViewTemplate = I copied the contents of the ViewTemplate into
a new tiddler named MyCustomViewTemplate
AddMedia = This is the tiddler where I put the <<formTiddler
OfflineMediaTemplate>> macro as well as the <data>{...}</data> fields
associated with the form. The AddMedia tiddler displays the form
created in OfflineMediaTemplate just fine.
OfflineMediaTemplate = Of course, this is the form I want to use for
the data entry.

When I click on the "try this" button in the Add OfflineMedia tiddler
to fire the macro, it just opens a new blank tiddler, only it opens in
view mode, rather than edit mode.

~Rex

Rex

unread,
Oct 16, 2007, 2:13:45 PM10/16/07
to TiddlyWiki
After reading http://tiddlywiki.com/#NewTiddlerMacro more closely, I
see that obviously, I can't just copy and paste the ViewTemplate and
expect the NewTiddlerMacro to work. I decided to swap out
MyCustomViewTemplate and used OfflineMediaTemplate instead. This put
me closer to where I want to go, but of course the new tiddler doesn't
render properly.

Where can I view some examples of customized view templates to get an
idea how to set one up for my form? This seems like such a powerful
feature, so I'm kind of surprised that I'm not finding more
information about how to create custom templates. I'm probably
looking in the wrong places.

~Rex

Xavier Vergés

unread,
Oct 16, 2007, 5:36:10 PM10/16/07
to TiddlyWiki
Rex,

what features are you missing if you use NewTiddlerWithForm or the
<<newSavedTiddler ...>> defined in the attached code in the thread
that you referenced in the initial post?

I think that the <<newSavedTiddler ...>> should give you anything that
you need...

Probably something like the next tiddler should work

==Add OfflineMedia==
/% This will have the value in the input field %/
<data>{}</data>
/% A part just to avoid having an additional tiddler with the form
template %/
<part FormTemplate hidden>
<html>
Title: <input name="title"><br/>
</html>
</part>
/% Show the form where the title is selected %/
<<formTiddler [[Add OfflineMedia/FormTemplate]]>>
/% A button to create a tiddler that uses the OfflineMediaFormTemplate
with some prefilled values
{{}} causes the macro params to be eval'ed
DataTiddler.getData gives access to the <data> section above
%/
<<newSavedTiddler


label:"try this"
prompt:"tooltip"

title:{{DataTiddler.getData("Add OfflineMedia","title")}}
text:{{'<data>{"mediaTitle":' + DataTiddler.getData("Add
OfflineMedia","title")+
'</data><'+'<formTiddler OfflineMediaFormTemplate>'+'>'}}
tag:offlineMedia>>

-Xv

Rex

unread,
Oct 17, 2007, 12:12:10 AM10/17/07
to TiddlyWiki
Xavier,
Thanks for the help. I guess I got sidetracked with the
newtiddlermacro thread and didn't follow up on using Saq's
newSavedTiddler macro. I ended up with the following code which seems
to be working.

<<newSavedTiddler label:"Add Reference to Offline Media"
template:ViewTemplate
text:{{store.getTiddlerText("AddMedia")}}
tags:"offlineMedia">>

I get prompted for a title, then the form I created opens up in view
mode and whatever data I enter in the form gets saved and tagged. I'm
not sure a hacker like me could ask for anything more :)

BTW, I did try the tiddler you suggested, but I kept getting an error
message and I don't understand js enough yet to decipher the error.

~Rex

Xavier Vergés

unread,
Oct 17, 2007, 2:05:01 AM10/17/07
to TiddlyWiki
> I get prompted for a title, then the form I created opens up in view
> mode and whatever data I enter in the form gets saved and tagged. I'm
> not sure a hacker like me could ask for anything more :)

Nice!

> BTW, I did try the tiddler you suggested, but I kept getting an error
> message and I don't understand js enough yet to decipher the error.

Nevrmind. Simpler (yours) is better. And I did not understand what you
were after.

Saq, how about moving the newSavedTiddler macro from an attachment to
http://tw.lewcid.org/sandbox/ ?

-Xv

Saq Imtiaz

unread,
Oct 17, 2007, 5:10:39 AM10/17/07
to Tiddl...@googlegroups.com

I'm planning on formally releasing a slew of plugins later this week, I'll make sure this gets in there too.
Cheers,
Saq

-Xv


) : a gallery of TiddlyWiki themes.
TiddlySnip ( http://tiddlysnip.com ) : a firefox extension that turns TiddlyWiki into a scrapbook!
LewcidTW ( http://tw.lewcid.org ) : a repository of extensions for TiddlyWiki
Reply all
Reply to author
Forward
0 new messages