How to automatically generate first line block by field?

Hi,

When opening a new tiddler, I start by typing “draft”.

when it gets complicated, I will change “draft” to “preview”.

When it is finally done, I will remove “draft” or “preview” from the tiddler text.

I have modified the first line many times and just wish there was an easy way to do it.

so what I asking is: How to automatically generate first line block by field?

For example:
add a new filed “status:draft” to the tiddler and automatically display “draft” in the first line.
changed the filed value “status:done” and it display nothing in first line.

I dont know if this is possible and how to implement this feature in TiddlyWiki. maybe someone can point me a way.

You can create a template
named eg: myStatusTemplate
tagged: $:/tags/ViewTemplate
list-before: $:/core/ui/ViewTemplate/body

with the following content

\whitespace trim
<$list filter="[all[current]get[status]]" variable="currentStatus">
  <$list filter="[<currentStatus>!match[done]]" >
    ''<<currentStatus>>''
    <hr>
  </$list>
</$list>

The first line with filter="[all[current]get[status]]" gets the status field from the current tiddler the template is shown in and sets the value to the variable “currentStatus”

So the content of the inner list <<currentStatus>> will contain that text of the field. So if you decide to use any other status-value you are good to go

The inner list with the filter="[<currentStatus>!match[done]]" checks if the currentStatus variable does not match “done”. … So it shows the content of the list.

if the value is done, it will show nothing.

The field: list-before is used to define the position in the ViewTemplate. By default it would be shown at the end of the tiddler. See docs about list-before

\whitespace trim … is there to remove the indentation in the code.

Important: If you want more complex text, you may need to remove the \whitespace trim pragma and the indents

Intro to lists in general can be found at: Introduction to Lists

have fun!

1 Like

If you would want to show something for status: done you could do this:

\whitespace trim
<$list filter="[all[current]get[status]]" variable="currentStatus">
  <$list filter="[<currentStatus>!match[done]]" emptyMessage="\o/ \o/ \o/ \o/ \o/ \o/ \o/ \o/ <hr>">
    ''<<currentStatus>>''
    <hr>
  </$list>
</$list>

emptyMessage is shown, if the the filter="[<currentStatus>!match[done]]" has an empty result.

The value of the inner-list can be seen in the <<currentTiddler>> variable, since there is no explicit variable parameter.

1 Like

Thank you for your teaching. very easy to understand and clear.

I have not seen this solution before. ViewTemplate is a magin tag in TiddlyWiki. I would like to learn more about it.

There are a lot of SystemTags in TW.

The most common one to be changed by users is the ViewTemplate. Then the EditTemplate and last but not least the PageTemplate.

The last overview tiddler in the link above shows all the System Tags, that are used to create the TW UI

have fun!

1 Like