Create New tiddler from search term if there are no tiddlers with that term

“If you type something in the search box that doesn’t exist, there should be a button below the search field such as “Create new tiddler with this title.”

I am quite sure this problem has been solved before. I’ve searched here and can find it. In my mind it was solved by Mohammad Rahmani. I’ve look in his project - no joy

I’ve got this far

<$edit-text tiddler="$:/temp/search" type=“search” placeholder=“Search or create” />
<$list filter="[[$:/temp/search]!text[]]">
<$button tooltip=“Create new tiddler with this title”>
{{$:/core/images/new-button}}
<$action-createtiddler title={{$:/temp/search}} />
</$button>
</$list>

any pointers most welcome

Alex

Here’s my suggestion:

\procedure createTarget()
<$action-createtiddler $basetitle={{!!newTarget}} >
<$action-sendmessage $message="tm-edit-tiddler" $param={{!!newTarget}} />
\end

\procedure editTarget()
<$action-sendmessage $message="tm-edit-tiddler" $param={{!!newTarget}} />
\end

<$edit-text field="newTarget"/>
<% if [{!!newTarget}!is[missing]] %> 
<$button actions=<<editTarget>> tooltip="Edit tiddler with this title">Edit</$button><br>//... target exist!//
<% else %> 
<$button actions=<<createTarget>> tooltip="Create new tiddler with this title" >New Target</$button>
<% endif %>

Feel free to ask questions and/or modify the snippet to meet your needs.

You may have a look at: Wikilabs Home — A home for: Plugins, Editions and Themes!

1 Like

Have a look at simple search: Plugins — Utilities for TiddlyWiki
Cheers, Thomas

1 Like

This functionality is already in the TWCore!
See Hidden Setting: Navigate on Enter.

By default,

  • Pressing ENTER will view whatever title you have typed, but only if it already exists.
  • Pressing CTRL-ENTER will edit whatever title you have typed, but only if it already exists.

To enable this same keyboard handling for missing tiddlers (i.e., titles that don’t yet exist):

  • Create $:/config/Search/NavigateOnEnter/enable with text content “yes”

enjoy,
-e

4 Likes

Thank Eric! It works really well.
Hidden settings!

Maybe in on TW-com there could be a tag “Creating Tiddlers” added to that hidden setting Tiddler.

Another idea: in the search box have a tip. Something that speaks in a voice that is in hour head.

“Create a new tiddler, control enter to create”

Alex

for my taste in UI behavior, I don’t think this should be hidden. It’s a useful option that should be a visible toggle in the control panel.

2 Likes

My plugin Simple Search has a + button for this.
https://tid.li/tw5/plugins.html

1 Like

Do you use Journal Tiddlers regularly? In a Journal Tiddler, you can type up your Search Queries in advance; thereby logging your own activity (for your own purposes). Then either:

1 Place [[]]around your query. If it shows up in italics, you know it doesn’t exist yet.
2 Copy the query and link it: CTRL+L. → Paste it into the search bar that pops up.

Another way of doing it.

1 Like

Wow! Thomas! That’s very nice!

Alex

1 Like