Adding a custom signature at the end of tiddlers

138 views
Skip to first unread message

Yann Rodrigues

unread,
Feb 8, 2016, 8:34:21 AM2/8/16
to TiddlyWiki
Hello world!

I'm currently trying to use Tiddlywiki to store some mail templates for my non-profit org..
I would like to use javascript to be able to store the name of the local user in order to put it in a signature at the end of each tiddler.

I tried to declare a variable with the following code (between the <head> marks):

<script>
var person = prompt("Please enter your name", "");
if (person != null) {
    document.getElementById("person").innerHTML =
    "person";
}
</script>

the prompt works fine and the variable is declared as I verified in the source code showed by Google Chrome, so it seems to work.

Now, I just need to know how to declare it in a tiddler.
I Would just like to add the name of the user declared in the variable in the signature, like this:

Regards,
<<person>>
My non profit organisation.

Anyone knows how I could do it, if it's possible?

Thank you all :) !

Jed Carty

unread,
Feb 8, 2016, 9:15:51 AM2/8/16
to TiddlyWiki
If you use tiddlywiki 5 (what is used on tiddlywiki.com) than you can do this without worrying about javascript.

Are you usign tiddlywiki 5? If not can you switch to it? For new users it is best to start with it because tiddlywiki classic is no longer being developed and doesn't have as much support.

Let us know which version you are using.

Also, if you can answer, what organization is it? That isn't important, I am just curious.

Yann Rodrigues

unread,
Feb 8, 2016, 9:25:47 AM2/8/16
to TiddlyWiki
I'm using TW5 I think (<meta name="tiddlywiki-version" content="5.1.9" />)

So if I understand there is a functionality for this kind of use? I'm stuck on it for almost one week so I thought about posting here, have I just started with the wrong idea x)

I don't know if it's an "organisation", I just used this word because I don't know hoe to translate "association" from French to English ^^. Basically doing stuff related with japanese culture, and we have some reccurent mails that we send to different entities ;).

Thank you for that reply ^^.

Jed Carty

unread,
Feb 8, 2016, 11:34:05 AM2/8/16
to TiddlyWiki
In that case you are making things much more complicated than it needs to be. There shouldn't be any reason for you to directly edit the html file. In fact that is generally a bad idea unless you know exactly what you are doing.

Here is one simple way to make what you want:

Create a tiddler called 'Set Username', give it the tag '$:/tags/TopLeftBar' and the text:

<div>User Name: <$edit-text tiddler='$:/state/User Name' field='name'/></div>



That will place a text input box in the upper left corner of the screen for the username. You can style this the same way you would any html element. If you want to move it somewhere else you can use the tag '$:/tags/PageTemplate' instead and use css to style the div element and move it wherever you want.

Then anywhere you put {{$:/state/User Name!!name}} it will display what is entered into the box instead.

The way to automatically add the signature like you asked depends on how you make the email tiddlers. The best way would probably be to give the tiddlers that have the emails in them a tag and then use a conditional view template (https://tobibeer.github.io/tb5/#Conditional%20ViewTemplate%20Section). That site also has a lot of other useful reference information. I also have a site I made with reference things here http://inmysocks.tiddlyspot.com/

Yann Rodrigues

unread,
Feb 9, 2016, 1:16:39 AM2/9/16
to TiddlyWiki
Oh... That was indeed simple! You really made my week with that solution, thank you so much! :D
Reply all
Reply to author
Forward
0 new messages