Change the title of a tiddler from the tiddler itself?

481 views
Skip to first unread message

si

unread,
Apr 27, 2021, 3:33:13 PM4/27/21
to TiddlyWiki
I've created a ViewTemplate that adds a table of editable metadata to any tiddler with the tag "Book". Here is a simplified example:

<$list filter=[all[current]tag[book]]>

|Book title|<$edit-text field=book-title />|
|Author|<$edit-text field=author />|

</$list>

Now I intend to set the title of these tiddlers to something like {!!book-title} - {!!author}. But I'd rather not do it manually, so I thought maybe I could use an action widget to automatically set the title as the fields are being edited:

\define actions()
<$action-setfield tiddler=<<currentTiddler>> title={{{ [{!!book-title}addsuffix[ - ]addsuffix{!!author}] }}}/>
\end

<$list filter=[all[current]tag[book]]>

|Book title|<$edit-text field=book-title inputActions=<<actions>> />|
|Author|<$edit-text field=author inputActions=<<actions>> />|

</$list>

Anyway you more enlightened folks will immediately see that this won't work, because the action-widget will create a new tiddler rather than edit the title of the current one.

So I'm wondering if there are any clever workarounds here? (I would also be happy with a button to set the title based on fields, but this approach seems to suffer from the same problem.)

Thanks in advance for your help.

PMario

unread,
Apr 27, 2021, 4:05:11 PM4/27/21
to TiddlyWiki
Hi,

Read this: https://tiddlywiki.com/#WidgetMessage%3A%20tm-rename-tiddler ... especially the "renameInxxx" parameters.

try:

\define actions()
<$action-sendmessage $message="tm-rename-tiddler" from=<<currentTiddler>> to={{{ [{!!book-title}addsuffix[ - ]addsuffix{!!author}] }}} />

\end

<$list filter=[all[current]tag[book]]>

|Book title|<$edit-text field=book-title />|
|Author|<$edit-text field=author />|

<$button actions=<<actions>>>click</$button>
</$list>

-mario

si

unread,
Apr 28, 2021, 3:26:25 PM4/28/21
to TiddlyWiki
Thank you very much Mario! I think a button may make more sense anyway, but am I right to assume that it is not (easily) possible to have the title automatically update as I type?

PMario

unread,
Apr 28, 2021, 7:17:05 PM4/28/21
to TiddlyWiki
On Wednesday, April 28, 2021 at 9:26:25 PM UTC+2 si wrote:
Thank you very much Mario!

You are welcome.

I think a button may make more sense anyway, but am I right to assume that it is not (easily) possible to have the title automatically update as I type?

Right. .. In TiddlyWiki the tiddlers are "immutable" [1]. They can't be changed, after they have been created. There actually is _no_ function in TW that says: Edit existing tiddler.

The only function to write to a tiddler is: $tw.wiki.addTiddler(...) Adding a tiddler with the same title, will overwrite the existing one. That's the only way to change a tiddler.

Let's say you have "New Tiddler" and you want to change it to "Faust - Goethe". As soon as you start typing F .. you add tiddler F, then Fa, Fau, Faus ... and so on.

 - create a new tiddler
 - Copy this into a new tiddler: <$edit-text tiddler=<<currentTiddler>> field=title />
 - Save
 - open the right sidebar : Recent tab   <- important
 - start typing

Nice - right?

have fun!
mario


Joshua Fontany

unread,
Apr 28, 2021, 7:26:30 PM4/28/21
to TiddlyWiki
@PMario,

That is a great way to explain what happens behind the curtains. :)

Best,
Joshua F

si

unread,
Apr 29, 2021, 6:35:07 PM4/29/21
to TiddlyWiki
Great, thanks a lot for the explanation :)

Mohammad

unread,
May 5, 2021, 12:35:34 AM5/5/21
to TiddlyWiki
On Thursday, April 29, 2021 at 3:47:05 AM UTC+4:30 PMario wrote:
On Wednesday, April 28, 2021 at 9:26:25 PM UTC+2 si wrote:
Thank you very much Mario!

You are welcome.

I think a button may make more sense anyway, but am I right to assume that it is not (easily) possible to have the title automatically update as I type?

Right. .. In TiddlyWiki the tiddlers are "immutable" [1]. They can't be changed, after they have been created. There actually is _no_ function in TW that says: Edit existing tiddler.

Is this true for other fields than title? I mean

  1.  if a new field is added to an existing tiddler? or
  2.  the value of a field is changed? or
  3. a new field is added?

or immutable only means changing the tiddler title?

Saq Imtiaz

unread,
May 5, 2021, 2:40:01 AM5/5/21
to TiddlyWiki
True for all fields. A field is changed by creating a new Tiddler with the same fields (including title) and updating the necessary field when creating that new Tiddler.

Mohammad Rahmani

unread,
May 5, 2021, 3:22:04 AM5/5/21
to tiddl...@googlegroups.com
Hi Saq,

On Wed, May 5, 2021 at 11:10 AM Saq Imtiaz <saq.i...@gmail.com> wrote:
True for all fields. A field is changed by creating a new Tiddler with the same fields (including title) and updating the necessary field when creating that new Tiddler.

I did not know this! So, tiddlers are immutable is a correct sentence! Is this the best way from performance point of view?


 
--
You received this message because you are subscribed to the Google Groups "TiddlyWiki" group.
To unsubscribe from this group and stop receiving emails from it, send an email to tiddlywiki+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/tiddlywiki/5059a0d6-a9a5-4578-a8c1-418e4284fce0n%40googlegroups.com.

PMario

unread,
May 5, 2021, 4:41:22 AM5/5/21
to TiddlyWiki
On Wednesday, May 5, 2021 at 9:22:04 AM UTC+2 Mohammad wrote:
On Wed, May 5, 2021 at 11:10 AM Saq Imtiaz <saq.i...@gmail.com> wrote:
True for all fields. A field is changed by creating a new Tiddler with the same fields (including title) and updating the necessary field when creating that new Tiddler.

I did not know this! So, tiddlers are immutable is a correct sentence! Is this the best way from performance point of view?

Editing internal memory would be faster, but it also creates some tricky problems. ...

In TWclassic it is possible to directly change "portions" of a tiddler from a plugin. The core sometimes doesn't see these changes. So it doesn't trigger a refresh cycle.

The plugin author has to trigger the refresh cycle. But the plugin author doesn't know, if a full or partial update is needed. So the common practice in plugins was to always trigger a full refresh cycle, just to be sure, that the core _and_ all other plugins see it.

This behavior wastes much more performance as creating a new tiddler does in TW5. In TW5 there is no other way to change something, without the core knowing about it. So the core tells every plugin, what happend.

I hope that makes it clearer. 

have
mario

Mohammad Rahmani

unread,
May 5, 2021, 11:00:12 AM5/5/21
to tiddl...@googlegroups.com
Yes! Thank you for your clarification!

have
mario

Best wishes
Mohammad

--
You received this message because you are subscribed to the Google Groups "TiddlyWiki" group.
To unsubscribe from this group and stop receiving emails from it, send an email to tiddlywiki+...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages