global Macro for new tiddler from templates

161 views
Skip to first unread message

Gerald Weis

unread,
Feb 20, 2020, 8:57:13 AM2/20/20
to TiddlyWiki
Hi folks,

i need help.

i want to create a new tiddler from templates.
The cocept ist, the macro shoud be global.

\define testknopf(Kennzeichen Sache)

<$button>
<$action-sendmessage $message="tm-new-tiddler" title="$Sache$ - Jahr" tags=$Kennzeichen$ $Sache$ text="{{Benzin - Jahr||$:/tags/Template}}"
</$button>
\end

This macro shoud do the follow things:
1. create a new tiddler
2. load the templatetiddler with Name where is compsite form "$Sache$ - Jahr"
3. transclude the content of templatetiddler in  the new tiddler
4. disable the templatetag in the new tiddler
4. close the templatetiddler

my Templatetiddler is tagged with $:/tags/Template

what ist wrong?

Mark S.

unread,
Feb 20, 2020, 10:03:52 AM2/20/20
to TiddlyWiki
There are at least 3 ways to make new tiddlers in TW. Of these, only the ActionCreateWidget will automatically prevent overwriting titles. ACW
also has the advantage that it doesn't open your tiddler in edit mode.

In your original you had text="{{transclusion}}" . You can not do that. You must use text={{transclusion}} . Otherwise, the actual text will be "{{transclusion}}" and not the transcluded content.

In your example, <$action-sendmessage was not closed on the end with "/>".  Always do a double-check to make sure that all tags are matched by their anti-tag
(e.g. <mytag> .... </mytag> or that a single tag is closed on the end with "/>" .

In your original example, I did not know what $:/tags/Template did or what it's contents were. So I removed it for my test.

This version works, though I don't know if it does exactly what you intended:

\define testknopf(Kennzeichen Sache)
<$button>Mein Knopf
<$action-createtiddler $basetitle="$Sache$ - Jahr" tags="$Kennzeichen$ $Sache$" text={{Benzin - Jahr}} />
</$button>
\end

<<testknopf ImportantTag Thing>>

If you press the button twice, it will make a new tiddler based on the name, but will not over write the first one.

HTH

Gerald Weis

unread,
Feb 20, 2020, 3:00:15 PM2/20/20
to TiddlyWiki
Hi Mark,

yes it do what i want.

but i have an problem

some tags have mor as one word.
than make this makro more as one tag from this.

example tag is "Reparatur und Wartung"
the Macro make the tags "Reparatur" "und" "Wartung"

what can i do that the tag ist one expression?

thanks

Mark S.

unread,
Feb 20, 2020, 3:14:44 PM2/20/20
to TiddlyWiki
Try changing the tag attribute like this:

tags="[[$Kennzeichen$]] [[$Sache$]]"

Gerald Weis

unread,
Feb 21, 2020, 8:14:46 AM2/21/20
to tiddl...@googlegroups.com
Hi Mark


i have the macro a little extended.
now the code is

\define NeuerZyklus(Kennzeichen Sache Jahr)
<$button>''$Sache$''<br>Jahr - ''$Jahr$''
<$action-createtiddler $basetitle="$Sache$ - $Jahr$" tags="[[$Kennzeichen$]] [[$Sache$]]" text={{$Sache$ - Jahr}} />
</$button>
\end

Now i have detected that i every time whlen i want write an new tiddler with this macro i must change the macrocall.
That is not so good. - My mistake sorry.

Is it posible to create an inputfield where enables the data to be circulated with the Variables into the macro?

thanks for your help



Beispiele


How i do that?

thanks for your help

PMario

unread,
Feb 21, 2020, 8:31:59 AM2/21/20
to TiddlyWiki
Hi Folks,

I did create a PR at github, that should make actions like this very simple. It improves the action-createtiddler widget with a $template and $overwrite parameter.

Please upvote the PR.


have fun!
mario

Mark S.

unread,
Feb 21, 2020, 10:48:24 AM2/21/20
to TiddlyWiki

You can use the edittext widget to allow input, if that's what you mean:

\define NeuerZyklus(Kennzeichen Sache Jahr)
<$button>''$Sache$''<br/>Jahr - ''$Jahr$''

<$action-createtiddler $basetitle="$Sache$ - $Jahr$" tags="[[$Kennzeichen$]] [[$Sache$]]" text={{$Sache$ - Jahr}} />
<
/$button>
\end
<$vars ph="Geben Sie den Text für den Tiddler ein">
Sache: <$edit-text tiddler="$:/
temp/Sache" tag=input size=50 placeHolder=<<ph>> default="Sache"/><br/>
Kennzeichen: <$edit-text tiddler="
$:/temp/Kennzeichen" tag=input size=50  placeHolder=<<ph>> default="Kennzeichen"/><br/>
Jahr: <$edit-text tiddler="
$:/temp/Jahr" tag=input size=10 placeHolder=<<ph>> default="2020"/><br/>
</$vars>
<$macrocall $name=NeuerZyklus Kennzeichen={{$:/temp/Kennzeichen}}  Sache={{$:/temp/Sache}} Jahr={{$:/temp/Jahr}} />


Gerald Weis

unread,
Feb 21, 2020, 1:24:04 PM2/21/20
to TiddlyWiki
Hi Mark

you are great

thanks
Reply all
Reply to author
Forward
0 new messages