Create a tiddler with pre defined fields

246 views
Skip to first unread message

passingby

unread,
Jan 24, 2018, 5:53:48 PM1/24/18
to TiddlyWiki
So in my TW I have tiddler in which I mention people's names, either in content or in a field. There are separate tiddlers containing information about these people. For example a tiddler's name john would have his contact information, some background information and how I know him personally etc. Usually I create a contact tiddler with all the various fields pre-defined and I just fill in some of them. For example, address, reference, email, phone etc. But sometimes while writing down an event I would mention some new names like [[jane]]. Now what I want is that when I click on [[jane]] from an event tiddler it should create a new contact tiddler with pre defined blank fields. What would be the best way to do it?

I thought on this line: 
Have an edit tiddler template which checks if a tiddler is tagged as contact. If it is then shows up a button which contains actions which create the relevant fields if not already existing. So then when I click on undefined tiddler [[jane]]. Missing tiddler jane comes up. Go into edit mode to create the tiddler. Tag it as 'contact'. As soon as i add the tag contact the button shows up which I click to add all the relevant fields in one go.

I have this template tiddler:

\define my-actions()
<$action-sendmessage $message="tm-add-field" $param="address"/>
<$action-sendmessage $message="tm-add-field" $param="phone"/>
<$action-sendmessage $message="tm-add-field" $param="email"/>
<$action-sendmessage $message="tm-add-field" $param="reference"/>


\end


<$list filter="[is[current]tag[contact]]">


<$button actions=<<my-actions>>>
Click to add contact fields
</$button>
</
$list>


So this system works, but can this be made better? Can I somehow do away with the button and trigger the "tm-add-field" message automatically as soon as the tiddler is tagged contact? or even better create a new contact tiddler with pre defined fields right from the tiddler link in the other tiddler mentioning the person's name?


Mark S.

unread,
Jan 24, 2018, 6:06:23 PM1/24/18
to TiddlyWiki
I think my way would be to make a macro and use it instead of links. Something like

<<contact jane>>

If "jane" exists, it displays a link. If "jane" doesn't exist, it displays a button labeled "jane". Click on the button to create the new "jane" tiddler. I haven't thought through the details, but I'm pretty sure all this is possible. I'm sure a macro that displays both a link and a button is possible, if nothing else.

Some others may have creative suggestions as well.

Good luck,

-- Mark

passingby

unread,
Jan 24, 2018, 6:12:24 PM1/24/18
to TiddlyWiki


On Wednesday, January 24, 2018 at 4:06:23 PM UTC-7, Mark S. wrote:
I think my way would be to make a macro and use it instead of links. Something like

<<contact jane>>

If "jane" exists, it displays a link. If "jane" doesn't exist, it displays a button labeled "jane". Click on the button to create the new "jane" tiddler. I haven't thought through the details, but I'm pretty sure all this is possible. I'm sure a macro that displays both a link and a button is possible, if nothing else.

Some others may have creative suggestions as well.

Good luck,

-- Mark

That is a good idea Mark. Ill try it out. Thanks again!  

TonyM

unread,
Jan 24, 2018, 6:27:19 PM1/24/18
to TiddlyWiki
Passingby,

I agree with Marks approach but think it could be enhanced by using a fields existence to define a tiddler as a contact eg full-name

Then in a tiddler tagged to appear in the view template, if the full-name field exists has[full-name] then it is a contact and you can provide tools for managing contacts.

Once the first field is created one or more create fields can be displayed/creation buttons provided etc... (if they do not exist)

If you design it correctly you can click on any tiddler link and make it a contact, or use <<contact jane>> to state it explicitly, or have the details for contacts display automatically when opening such tiddlers. 

This advice is only general in nature


Regards
Tony

passingby

unread,
Jan 26, 2018, 12:04:15 AM1/26/18
to TiddlyWiki
@Tony Thank you for your suggestions.

For now i am trying to create a macro as suggested by Matt but how does one check for a tiddler's existence?

passingby

unread,
Jan 28, 2018, 1:21:10 AM1/28/18
to tiddl...@googlegroups.com
After some efforts I stumbled upon this solution for a macro which displays a tiddler link if the contact tiddler exists and a button to create one if it does not. Please have a look and let me know if this is actually a proper way to do it or should i be doing in some other way:

\define contact(name)
<$list filter="[title[$name$]is[missing]]">


<$button>
<$action-createtiddler
$basetitle
='$name$'
tags
='contact'
address
=''
phone
=''
email
=''
reference
=''
birthday
=''
$savetitle
={{ContactMacro!!newContact}}
/>
<$action-sendmessage $message="tm-edit-tiddler" $param={{ContactMacro!!newContact}}/>
create $name$
</$button>
</
$list>
<$list filter="[title[$name$]is[tiddler]]">
[[$name$]]</$list>
\end

So simply the first list filter displays a button to create a tiddler with pre defined fields if the tiddler does not exist. In the second list widget if the tiddler exists a tiddler link is displayed.

My concerns and confusion is:

1. It seems that list widget is being used for something other than what it is supposed to be used for. It is meant for producing lists, whereas here it is being used as a mode for implementing a check. Isn't this a hackish, non-standard way?
2. I could not find any way to implement an if-then-else logic. Is this so, that it is not possible using provided widgets?
3. Lastly how do I implement  AND and OR filters in a list widget? 

Mark S.

unread,
Jan 28, 2018, 12:29:39 PM1/28/18
to TiddlyWiki
1. Kludgey, or pure genius depending on how you look at it.
2. No deliberate logic tools baked in. Yet. Possibly you could have 2 filter runs, each testing for a condition opposite the other one.
3. In a filter run, everything is basically asking AND (this tag AND this prefix AND...). But you can have more than one run in a filter expression, which serves as a kind of OR.

BTW, it looks like you're doing really good!

-- Mark

passingby

unread,
Jan 28, 2018, 3:20:01 PM1/28/18
to TiddlyWiki
Thank you Mark for input and for the encouragement. I too feel that I am getting little more familiar with TW5 now. As and when I encounter a need to create a list or a button or change something I face an obstacle and in overcoming that obstacle, does the learning occur. Its enjoyable, except for the time it takes up ( and time is always on shortage).
Reply all
Reply to author
Forward
0 new messages