Open a tiddler or create if it does not exist

57 views
Skip to first unread message

passingby

unread,
May 17, 2019, 2:41:20 PM5/17/19
to TiddlyWiki
I am trying to create child tiddlers of Journal tiddler. Every journal would have a  few button which would either create a child tiddler or open if one already exists. Is there a way to accomplish this?

passingby

unread,
May 17, 2019, 3:07:40 PM5/17/19
to TiddlyWiki
I am thinking along these line. 

<$list filter="[tag[sometag]is[missing]]">
It is missing . Show a button to create a tiddler here
</$list>
<$list filter="[tag[sometag]is[tiddler]]">
It exists. Show a button to open the tiddler.
</$list>

The second logic works but the first one does not because the list does not 'run' when the check fails.

passingby

unread,
May 17, 2019, 3:25:52 PM5/17/19
to TiddlyWiki
I think I got it. All I need is second logic construct and put the other logic in the parameter "emptyMessage", which is the message displayed when the list does not run:

<$list filter="[tag[sometag]is[tiddler]]" emptyMessage="Does not exist. Show a button using a macro to create it!" >
It exists. Show a button to open the tiddler.
</$list>


TonyM

unread,
May 18, 2019, 8:09:58 AM5/18/19
to TiddlyWiki
Passingby

The following may be obvious but worth remembering.

If you have no need to use a template or apply tags to create a new tidder, a simple link even [[new tiddler]] is enough. The new here button helps create tiddlers tagged with the current of course.

but all the sophisticated options are available and I can help with those as I have studied them.

Regards
Tony

passingby

unread,
May 18, 2019, 12:03:36 PM5/18/19
to TiddlyWiki
Tony,

Thank you for your input. What I am trying to accomplish is create a food journal for personal health issues. The target is to record everything I eat or drink and record the symptoms that follow. The general idea is create a journal tiddler. It should have a custom view template which displays a kind of a menu with buttons in which I can create child tiddlers such as events: breakfast/lunch/dinner/snack, drink, medication/supplement, exercise/yoga/, Stress, Sleep. And then outcomes: physical symptoms, energy level, mood, main thoughts(spiritual/job-related/creativity-related etc). 

I was thinking I should have the child tiddlers such as events and outcomes show up in a modal state. They should have a simple and minimal layout with all the fields being displayed. Then there should (preferably) be to buttons to either cancel or confirm the data change.

In order to create a view template in which fields can be displayed I am taking help from technique used by http://tw5magick.tiddlyspot.com/ in the tiddler [[Creating a simple Contacts DB]]. I have tiddler which shows a form whose fields are linked with the child tiddler. The name of the child tiddler is picked up from another tiddler something like $:/_temp/meal. So the way it happens is that whenever the button is pressed on the journal to show a child tiddler, the name of that child is saved into  $:/_temp/meal and then the form tiddler is shown in a modal. The form tiddler then shows up the data because its fields are picking up the name from  $:/_temp/meal.

The problem right now is whether it is possible to have a save/cancel mechanism on the form tiddler. I don't think this is possible because in this process the actuall child tiddler is not being put into an edit mode and the tm-edit-tiddler event is not being fired and therefore tm-cancel-tiddler cannot be used. So this is the problem right now.

If I think about not taking this path but showing the actual child tiddler in an edit mode, then I do not know how to change the editTemplate as to per my taste. Because what I want in that is, have a clean simple form and 2 buttons with cancel or confirm operations.
So this is where I am at. Any suggestions or pointers or even a different approach altogether is welcome.


passingby

unread,
May 18, 2019, 6:29:12 PM5/18/19
to TiddlyWiki
As an update I have decided to not to use modals, and use the natural tiddlywiki flow by using the zoomin story view instead. I want to make something that works in all the ways not just depend on modals. 
Reply all
Reply to author
Forward
0 new messages