How to show part of the title in another field

Hello all

I have a journal tiddler whose title is in the form:
2023-01-01 : This is the title
I would like to display the first 10 characters of the title in a field called date.

Is there a way of doing this using the $view widget?

Welcome to the community!

If you are committed to this format (and you always have a space before the colon) then the easiest way is just

{{{ [{!!title}split[ ]first[1]] }}}

Still, I wonder whether you want to set the date field (so that it literally holds the string 2023-01-01 — even if you were to change the title later), or whether you just want to display it in a way that always reflects the first part of whatever the title currently is…

If you just want to display that initial string easily, and you will keep this uniform way of titling tiddlers, it’s unclear whether you need a separate date field at all, rather than a macro.

If you set up a tiddler with the contents below, and tag it $:/tags/Macro then you can insert <<tid_date>> in any tiddler to show that first (pre-space) part of its title…

\define tid_date()
{{{ [{!!title}split[ ]first[1]] }}}
\end

The best solution depends on what you’re doing with this date field!

If you want to do interesting things with the date field (such as compare the date field to the current day, or find tiddlers created on that day, etc.), you might also consider whether it would be helpful to set the date field in TiddlyWiki’s date-string format, which looks like 2023010112 (I always add the 12 at the end to minimize the chance of time zone differences resulting in date confusion. The date-time string can keep going to 3 decimal places after the minutes and seconds value, but leaving out the extra digits is like filling them in as zeros.)

1 Like

[Edited] to fix typos, sorry

Personally I have modified the new journal button to set a journal-date field to the journal date, using a tiddlywiki serial date format. No need to “deconstruct the title”.

  • Personally I believe this should be in the core.

I think @Springer is on track, but If I were to do as you ask (not recommended) I would do this;

{{{ [all[current]split[:]first[]trim[]] }}} ← added trim

The full title to tw date serial is

{{{ [all[current]split[:]first[]split[-]join[]trim[]addsuffix[120000000]] }}}

The short title is {{{ [all[current]split[:]last[]trim[]] }}}

Notes

  • I use trim to remove some spaces that sneak in, from your titles. " : "

The issue now is getting the value into a field because setting fields needs a button trigger. That is why I set journal-date at journal creation, to save the need for an additional trigger.

2 Likes

As @TW_Tones points out, there are many ways to make TiddlyWiki fit well with your workflow.

If the thing you most often do is set up this kind of tiddler, then having something like the “new journal here” button – but working instead as a “new project button” (or whatever your category is) – could be a good approach.

In particular, once your tiddler is created with a particular tag, you can have its editing interface display with a custom edit template, so your edit interface to have the same kinds of layout of prompts that you described above for the new-tiddler-creation workflow you imagined.

And one more useful filter you might choose to use is [{!!title}split[]first[10]join[]].