"Fun" with title copy/edit

9 views
Skip to first unread message

David Sevilla

unread,
Aug 12, 2008, 5:40:43 PM8/12/08
to TiddlyWiki
Hi,

I started my first TW yesterday but I already had grandiose ideas from
the beginning :) I am trying to do the following: a template that
contains some tabs, where the embedded tiddlers have titles related to
the main tiddler. For example, the template is "NewTemplate" and
contains:

<<tabs txtFavourite
One "One" [[NewTemplate/One]]
Two "Two" [[NewTemplate/Two]]
Three "Three" [[NewTemplate/Three]]
>>

Now, the complication is that when I create a tiddler based on this
(with newTiddler) I want the "NewTemplate" in the tabs substituted by
the new title. I tried several combinations:

<script>return
"[["+story.findContainingTiddler(place).getAttribute("tiddler")+"/
Asd]]";</script>
<<view title>>/One
<script>document.write(""+story.findContainingTiddler(place).getAttribute("tiddler")
+"/One");</script>
They give the correct text outside the macro, but when I try inside
the code is messed up.

Am I being too ambitious? In any case, I want this for an address book
(I didn't find the FormTiddlerPlugin technique so good, I want more
versatility). I might just go and use someone else's, but my pride is
on the line ;)

Thanks a lot,

David

Eric Shulman

unread,
Aug 12, 2008, 6:00:29 PM8/12/08
to TiddlyWiki
> <<tabs txtFavourite
> One "One" [[NewTemplate/One]]
> Two "Two" [[NewTemplate/Two]]
> Three "Three" [[NewTemplate/Three]]
> >>
> Now, the complication is that when I create a tiddler based on this
> (with newTiddler) I want the "NewTemplate" in the tabs substituted by
> the new title. I tried several combinations:

Hi David!

Welcome to the party... it seems that you've jumped right into the
deep end :-)

Give this a try:

First, install
http://www.TiddlyTools.com/#CoreTweaks
(specifically, see ticket #444, http://trac.tiddlywiki.org/ticket/444)
This will add a 'fixup' for the global variable, 'tiddler', which is a
reference to the current tiddler object, and is available for use in
*evaluated macro parameters*, like this:

<<tabs txtFavourite
One "One" {{tiddler.title+"/One"}}
Two "Two" {{tiddler.title+"/Two"}}
Three "Three" {{tiddler.title+"/Three"}}>>

enjoy,
-e
Eric Shulman
TiddlyTools / ELS Design Studios

David Sevilla

unread,
Aug 13, 2008, 2:01:21 PM8/13/08
to TiddlyWiki

On Aug 13, 12:00 am, Eric Shulman <elsdes...@gmail.com> wrote:
> > <<tabs txtFavourite
> > One "One" [[NewTemplate/One]]
> > Two "Two" [[NewTemplate/Two]]
> > Three "Three" [[NewTemplate/Three]]
>
> > Now, the complication is that when I create a tiddler based on this
> > (with newTiddler) I want the "NewTemplate" in the tabs substituted by
> > the new title. I tried several combinations:
>
> Hi David!
>
> Welcome to the party... it seems that you've jumped right into the
> deep end :-)
>
> Give this a try:
>
> First, install
> http://www.TiddlyTools.com/#CoreTweaks
> (specifically, see ticket #444,http://trac.tiddlywiki.org/ticket/444)
> This will add a 'fixup' for the global variable, 'tiddler', which is a
> reference to the current tiddler object, and is available for use in
> *evaluated macro parameters*, like this:
>
> <<tabs txtFavourite
> One "One" {{tiddler.title+"/One"}}
> Two "Two" {{tiddler.title+"/Two"}}
> Three "Three" {{tiddler.title+"/Three"}}>>

Hi,

Thanks, it works like a charm! Just for the record, I write here my
solution for a tabbed address book with no forms. I have installed the
plugins CoreTweaks, EditTiddlerPlugin, ForEachTiddlerPlugin (which I
don't use) and InlineJavascriptPlugin.

1. Create "TemplateContact" with the text:

<<tabs txtFavourite
Main "Main" {{tiddler.title+"/Main"}}
Work "Work" {{tiddler.title+"/Work"}}
Personal "Personal" {{tiddler.title+"/Personal"}}
Misc "Misc" {{tiddler.title+"/Misc"}}
>>

In this way, a tiddler "Person" created with this content will have
tabs whose contents are those of "Person/Main", etc.

2. Create "TemplateContact/Main" etc. according to your own needs. A
sample:

@@display:block;text-align:right;<<editTiddler here "change
me">>@@First name:
Last name:
Birthday:

(The thing between the "@@" will create a "change me" button that will
edit "Person/Main" once we have created the contact "Person" in the
following step)

3. Now create "NewContact" which will contain the code that creates
all the tiddlers:

<script label="click here">
var title = prompt("Please enter contact's name", "");
store.saveTiddler(title+"/Main", title+"/Main",
store.getTiddler("TemplateContact/Main").text,
config.options.txtUserName, new Date());
store.saveTiddler(title+"/Work", title+"/Work",
store.getTiddler("TemplateContact/Work").text,
config.options.txtUserName, new Date());
store.saveTiddler(title+"/Personal", title+"/Personal",
store.getTiddler("TemplateContact/Personal").text,
config.options.txtUserName, new Date());
store.saveTiddler(title+"/Misc", title+"/Misc",
store.getTiddler("TemplateContact/Misc").text,
config.options.txtUserName, new Date());
store.saveTiddler(title, title,
store.getTiddler("TemplateContact").text, config.options.txtUserName,
new Date(),["Tag1","Better tagged"]);
story.displayTiddler(null, title, DEFAULT_VIEW_TEMPLATE);
</script>

4. This tiddler will have "click here", which will prompt for a title
when clicked. Let's say that we type "Example". Then it will create
"Example/Main" (with the contents of "TemplateContact/Main"), etc.,
and "Example" with the same contents as "TemplateContact", so that the
tabs will show the newly created tiddlers. "Example" will have tags
"Tag1" and "Better tagged" in this case.

5. Once it works, customize at will: change the template and
subtemplates to whatever you need.

I hope it's more or less clear... any comments appreciated!

Regards,

David

Eric Shulman

unread,
Aug 13, 2008, 4:22:53 PM8/13/08
to TiddlyWiki
> 1. Create "TemplateContact" with the text:
> 2. Create "TemplateContact/Main" etc. according to your own needs.
> 3. Now create "NewContact" which will contain the code that creates
> all the tiddlers:

Rather than creating separate tiddlers for each contact tab, you might
wnat to consider using "tiddler sections" to store the individual tab
content so that each individual contact record can be kept in a single
tiddler instead of a set of similarly named tiddlers. This would
simplify the entire process of creating a new contact, as well as
significantly reduce the number of tiddlers listed in the sidebar,
making it easier to manage each individual contact.

To do this, you could try defining your [[TemplateContact]] like this:
---------------------------------
/%
!!!Main
First name:
Last name:
Birthday:
!!!Work
...work stuff...
!!!Personal
...personal stuff...
!!!Misc
...other stuff...
!!!end
%/<<tabs txtFavourite
Main "Main" {{tiddler.title+"##Main"}}
Work "Work" {{tiddler.title+"##Work"}}
Personal "Personal" {{tiddler.title+"##Personal"}}
Misc "Misc" {{tiddler.title+"##Misc"}}>>
---------------------------------
The tab content is divided into *named* sections using the heading
("!") syntax, which are surrounded by comment markers so they won't be
*directly* displayed when the tiddler is viewed. Instead, these
'hidden' sections will be shown within the <<tabs>> macro by using the
"TiddlerName##sectionname" syntax.

To create a new contact, just use <<newTiddler>> with the
[[TemplateContact]] content as the default text. Because you don't
need to create a set of tiddlers, there's also no need to separately
prompt for a name for that contact. Just create a new contact tiddler
and give it a name in the usual way... then edit the content to fill
in the sections.

Note: because the entire contact data set is stored in a self-
contained tiddler, there's no need to have a separate 'edit' command
in each tab... simply edit the entire tiddler, find the section you
want, and start editing.

Also, there is one minor limitation with this 'section' approach: you
can't use the heading syntax (!) to format the content *within* a
section, since the heading syntax is being used to delimit the
sections themselves.

enjoy,
-e

David Sevilla

unread,
Aug 13, 2008, 5:03:40 PM8/13/08
to TiddlyWiki


On Aug 13, 10:22 pm, Eric Shulman <elsdes...@gmail.com> wrote:
> > 1. Create "TemplateContact" with thetext:
> [[TemplateContact]] content as the defaulttext. Because you don't
> need to create a set of tiddlers, there's also no need to separately
> prompt for a name for that contact. Just create a new contact tiddler
> and give it a name in the usual way... theneditthe content to fill
> in the sections.
>
> Note: because the entire contact data set is stored in a self-
> contained tiddler, there's no need to have a separate 'edit' command
> in each tab... simplyeditthe entire tiddler, find the section you
> want, and start editing.
>
> Also, there is one minor limitation with this 'section' approach: you
> can't use the heading syntax (!) to format the content *within* a
> section, since the heading syntax is being used to delimit the
> sections themselves.

Very neat :)

Thanks,

David
Reply all
Reply to author
Forward
0 new messages