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

3 Likes