How to combine two fields to get a title?

104 views
Skip to first unread message

Giannis Moutsinas

unread,
Mar 28, 2020, 5:02:53 PM3/28/20
to TiddlyWiki
I have created a simple form tiddler that I want to use to create other tiddler. My form tiddler takes data from another tiddler called [[temp]] and has a button that creates the new tiddler:
<$button>
<$action-createtiddler $basetitle="title" tags="person" name={{temp!!name}} surname={{temp!!surname}} />
Create
</$button>
What I want to do is to give the name of a person as a title. For example if the name is "John" and the surname is "Doe", I would like the new tiddler to be titled "John Doe". I had several attempts but nothing worked. How do I do that?


TonyM

unread,
Mar 28, 2020, 5:36:00 PM3/28/20
to TiddlyWiki
Try the following, untested by me now.

\define fullname() {{temp!!name}} {{temp!!surname}}

Then use <<fullname>> at the title

Tony

Mohammad

unread,
Mar 28, 2020, 5:41:34 PM3/28/20
to TiddlyWiki
This is related to concatenation strings and quite alot discussed here! Yes it is confusing!

If you have name in name and surname in surname field of temp tiddler, then to create a concatenated one you have several choice!
One simple solution is like this

<$vars fullName={{{ [{temp!!name}addsuffix[ ]addsuffix{temp!!surname}] }}}>
<$button>
<$action-createtiddler $basetitle=<<fullName>> tags="person" name={{temp!!name}} surname={{temp!!surname}} />
Create
</$button>
</$vars>


You will get better solution from geeks here :-)

--Mohammad

Mohammad

unread,
Mar 28, 2020, 5:43:51 PM3/28/20
to TiddlyWiki
Tony!
 Strangely this does not work! Except you use a wikify widget!!

--Mohammad

TonyM

unread,
Mar 28, 2020, 6:35:38 PM3/28/20
to TiddlyWiki
Thanks Mohammad

My next suggestion would be triple curly braces and a filter like yours.

Thanks for the correction.

Tony

Mark S.

unread,
Mar 28, 2020, 7:23:52 PM3/28/20
to TiddlyWiki
When you want to use a macro for concatenation, you need to use the special macro variables. Either $variable$ or $(variable)$. The latter is often most useful.

\define basetitle() $(name)$ $(surname)$
<$vars name={{temp!!name}} surname={{temp!!surname}}>
<$button>
<$action-createtiddler $basetitle=<<basetitle>> tags="person" name=<<name>> surname=<<surname>> />
Create
</$button>
</$vars>

Giannis Moutsinas

unread,
Mar 28, 2020, 7:40:15 PM3/28/20
to TiddlyWiki
Hi Tony,

This was actually one of the things that I tried and it didn't work. I still don't understand why. :)

TonyM

unread,
Mar 28, 2020, 7:51:58 PM3/28/20
to TiddlyWiki
I think it may need wikify(ing)

I normally test before posting, because my intuition is not always correct with tiddlywiki, I was oin my mobile and did not test it, sorry.

Trust marks suggestion for now!

Regards
Tony

Giannis Moutsinas

unread,
Mar 28, 2020, 8:00:20 PM3/28/20
to TiddlyWiki
This worked just fine. Thanks. A quick question how can I concatenate with a constant string. For example if I want to have a title of the form "Mr John Dow", how do I write that. I tried
{{{ "Mr "addsuffix[ ][{temp!!name}addsuffix[ ]addsuffix{temp!!surname}] }}}
and
{{{ [Mr ]addsuffix[ ][{temp!!name}addsuffix[ ]addsuffix{temp!!surname}] }}}
but they didn't work.

Giannis Moutsinas

unread,
Mar 28, 2020, 8:47:38 PM3/28/20
to TiddlyWiki
I solved my problem by following Mark's advice.

Thanks!

Mohammad

unread,
Mar 29, 2020, 1:19:30 AM3/29/20
to TiddlyWiki
Giannis,
 One place to learn these kind of operations is TW-Scripts, for example in your case see


--Mohammad

Giannis Moutsinas

unread,
Mar 29, 2020, 9:04:09 PM3/29/20
to TiddlyWiki
Thanks! :)
Reply all
Reply to author
Forward
0 new messages