Problem with a button operation

Hello everyone.
I’m trying to adapt a macro I found on a wiki to suit my needs but I can’t get it to work. It is a button that creates a tiddler with some predefined fields.
The button code is:

<$button actions={{$:/xp/ui/Actions/new-people}} tooltip="Create a new people" aria-label="new people" class="tc-btn-invisible tc-btn-mini">
<span class="tc-btn-icon">{{$:/core/images/new-button}}</span> new people
</$button>&emsp;<small class="tc-sidebar-header">(<i><$count filter='[tag<aggregationTag>!has[draft.of]]'/> tiddlers</i>)</small>&emsp;<$button to="$:/people-help" tooltip="PEOPLE Help" class="tc-btn-invisible tc-btn-mini">
<span class="tc-btn-icon">{{$:/core/images/help}}</span>
</$button>
</div>

The content of the tiddler $:/xp/ui/Actions/new-people that I replace with mine is as follows:

\define get-tags() $(textFieldTags)$
\define get-text() $(textField)$
<$vars textFieldTags={{$:/config/new-people/Tags}} textField={{$:/config/new-people/Text}}>
<$action-sendmessage $message="tm-new-tiddler" title=<<now "people-YYYY0MM0DD0hh0mm0ssXXX">> tags=<<get-tags>> text=<<get-text>> caption="a people" color="" description="" education="" lifetime="" image=""/>
</$vars>

This is the model ($:/model/person-2) that I try to make the button execute but I can’t get it to do so:

\define createNewItem()
  <$action-sendmessage 
    $message="tm-new-tiddler" 
    title=<<unusedtitle """New $(new-item-title)$""">> 
    tags="[[$(currentTiddler)$]]" 
    foto="$:/plugins/kookma/thinkup/images/mr_avatar"
    caption="name and title"
    text=<<content>>
    keywords=""
	nombre=""
	direccion=""
	localidad=""
	fecha_nac=""
	telefono_f=""
    />
\end


\define content()

<$macrocall $name=image-pretty img={{!!foto}} align="right" caption={{!!caption}} tooltip={{!!caption}} alt=""/>

<table class="table-borderless source">
<tr><th>Nombre</th><td>{{!!nombre}}</td></tr>
<tr><th>Dirección</th><td>{{!!direccion}}</td></tr>
<tr><th>Localidad</th><td>{{!!localidad}}</td></tr>
</table>

: <<.lorem>>

;Observaciones
: <<.lorem>>

\end

I’ve been doing several tests but I can’t get it to work. Can you tell me what I’m doing wrong, or what I have to change?

Thanks in advance.

1 Like

What I have done so far is change $:/xp/ui/Actions/new-people to $:/model/person-2, I have also tried to remove some parameters from the macro but it hasn’t worked…

You have imbalanced <div> here!

The $button works for me! What do you want to achieve?

Hi Hohammad.

Yes, when copying the button code I missed the </div>.

The code that I use and that does not work for me is this:

<$button actions={{$:/model/person-2}} tooltip="Create a new people" aria-label="new people" class="tc-btn-invisible tc-btn-mini">
<span class="tc-btn-icon">{{$:/core/images/new-button}}</span> new people
</$button>&emsp;<small class="tc-sidebar-header">(<i><$count filter='[tag<aggregationTag>!has[draft.of]]'/> tiddlers</i>)</small>&emsp;<$button to="$:/people-help" tooltip="PEOPLE Help" class="tc-btn-invisible tc-btn-mini">
<span class="tc-btn-icon">{{$:/core/images/help}}</span>
</$button>

I’ve tried it on another wiki and it doesn’t work for me either. However if I change $:/model/person-2 to $:/xp/ui/Actions/new-people it works and I don’t know why.

Hello Juan,
I think in $:/model/person-2 you merely define two macros, but nowhere call the createNewItem macro. You could just call the $action-sendmessage directly without wrapping it in a macro. Your $:/model/person-2 then would look like this:

\define content()
<$macrocall $name=image-pretty img={{!!foto}} align="right" caption={{!!caption}} tooltip={{!!caption}} alt=""/>
<table class="table-borderless source">
<tr><th>Nombre</th><td>{{!!nombre}}</td></tr>
<tr><th>Dirección</th><td>{{!!direccion}}</td></tr>
<tr><th>Localidad</th><td>{{!!localidad}}</td></tr>
</table>

: <<.lorem>>
;Observaciones
: <<.lorem>>
\end

<$action-sendmessage 
  $message="tm-new-tiddler" 
  title=<<unusedtitle """New $(new-item-title)$""">> 
  tags="[[$(currentTiddler)$]]" 
  foto="$:/plugins/kookma/thinkup/images/mr_avatar"
  caption="name and title"
  text=<<content>>
  keywords=""
  nombre=""
  direccion=""
  localidad=""
  fecha_nac=""
  telefono_f=""
  />

or adding a macro call <<createNewItem>> at the end of your version of $:/model/person-2 should also suffice to launch the action.

You could also make the macros global by adding the $:/tags/Macro tag to $:/model/person-2 and change the button actions to actions="<<createNewItem>>".

Have a nice day
Yaisog

See the @Yaisog answer above! As he said, $:/model/person-2 does nothing in your code.
The code by @Yaisog works.

Some simple examples for a button creates a tiddler

  1. Scripts in Tiddlywiki — codes, macros, and solutions in TW
  2. Scripts in Tiddlywiki — codes, macros, and solutions in TW
  3. Scripts in Tiddlywiki — codes, macros, and solutions in TW
  4. Scripts in Tiddlywiki — codes, macros, and solutions in TW

Thank you very much Yaisog! :smiley:

With what you have told me everything has worked wonderfully. The problem was that I was using a model to generate a new tiddler using the Mehregam mechanism and with this other system it didn’t work for me.

Have a nice day

Thank you very much for the information Mohammad!

I don’t know if you’ve seen it, but on the Fish for you website you mentioned the other day (https://tw5s.vercel.app/) there is a section with links.

There you have the one from TiddlyWiki XP (TiddlyWiki xp — A chance to experience TiddlyWiki very quickly) that I think can give you ideas for Mehregam, or not…

It’s given me quite a few ideas for what I’m doing, but I can’t get to the implementation level used on that page, so I’ll use what I can and understand. :sweat_smile:

I’m trying to translate the different plugins into English since it has quite a few comments and annotations in Chinese, if I manage to finish the translation I’ll upload it here. There is a link on TiddlyWiki XP where you can download all the plugins the author has created and the ones he uses on his wiki.

Another page that I also liked is — Read the Word,Read the World., although the latter although I can download it to my computer, then I am not able to open it locally…

All the best.

1 Like

Hi Juan,
I think there is no need for translation (not sure). @linonetwo may have some advices here.
BUT first do this

  • From sidebar open More tab
  • In the More Tab look for language (you can see the flag)
  • Change the language to English

Wonderful. If you have time, please add this to Showcase (like this one: Daily Notes and Interstitial Journaling by Scott Kingery)

TBH, the Chinese community of TiddlyWiki have recently produced great Editions/Plugins !