Tiddler reference

Hello. A very simpe question!
I have a wiki with a journal tiddlers whose titles are in the form YYYY-DD-MM. There are corresponding data tiddlers with a number of fields whose titles are YYY-DD-MM Data.

I want to use the $view widget in the journal tiddlers to show the content of the fields in the data tiddlers.

Please can someone show me how to reference the data tiddler by joining the title of the journal tiddler with the literal text ‘Data’.

I hope that makes sense.

Thanks in anticipation

You can use a “filtered transclusion” (the three curly braces syntax) to assemble the desired tiddler title, like this:

<$view tiddler={{{ [<currentTiddler>] [[Data]] +[join[ ]] }}} field="..." />
1 Like

Have you tried the “new Journal here” button?

I prefer to modify the new journal buttons to set a journal-date field so I can use that rather than try to extract it from the title. This frees the title for any format, suffix or prefix that does not interfear with any dates. I use the full TiddlyWiki serial date number which includes time etc…

  • Just ask and I will share my buttons, but you may already find them in the forum.
  • Thus I would format the new title(s) as [all[current]get[journal-date]format:date[YYYY-DD-MM Data]]
    • I would also save the whole journal-date in a field of the new tiddler.
    • Using this as the base title to action create tiddler will also add a number to the end of multiple tiddlers with the same

<$view tiddler=`$(currentTiddler)$ Data` field="...." />

@EricShulman You can simplify your filter with addsuffix.

<$view tiddler={{{ [<currentTiddler>addsuffix[ Data]] }}} field="..." />

From what I have read here, there is no worry about performance for this kind of things, The choice is a matter of taste.

1 Like

I prefer using the +[join[ ]] technique, especially in examples, because it demonstrates the general technique for using filtered transclusions to assemble text from parts.

For a more complex use-case where the text is assembled from multiple parts, addsuffix[...] (and/or addprefix[...]) starts to become very verbose. Also, if some of the parts are not a simple text values or variable references, then you can’t always use addsuffix[]… at least not easily.

For example, consider the case where you want to join some text that is retrieved from fields in some arbitrary tiddler whose title is stored in a variable like <myInput>:

<$let sometext={{{ [[Hello]] [<myInput>get[first_name]] [<myInput>get[last_name]] +[join[ ]] }}}>

In contrast, to do this using addsuffix[] you would need to get the first/last name values into variables and add the spaces between parts separately, like this:

<$let first={{{ [<myInput>get[first_name]] }}} last={{{ [<myInput>get[last_name]] }}}
<$let sometext={{{ [[Hello]addsuffix[ ]addsuffix<first>addsuffix[ ]addsuffix<last>] }}}>

and if the first_name field was empty, you would end up with two adjacent spaces.

-e

@EricShulman Very good points indeed! As a matter of fact, I belive that I have some bits of code to refactor in taking this into account.

So, many thanks!