Create tiddler with multiple tags, included transcluded and selected values

135 views
Skip to first unread message

Steven Schneider

unread,
Feb 17, 2017, 11:24:28 PM2/17/17
to TiddlyWiki
Hi folks, I'm interested in creating new tiddlers with multiple tags, some transcluded and others established by a select widget.

Here is my code:
1 Make sure there is a username: {{$:/status/UserName}}<br>

2 Select tag:
<$select tiddler='$:/newtag'>
<option>A Tale of Two Cities</option>
<option>A New Kind of Science</
option>
<option>The Dice Man</option>
</
$select>

3 Create tiddler with two tags

* username: {{$:/status/UserName}}
* newtag: {{$:/newtag}}

4 Create new tiddler

<$button>
<$action-sendmessage $message="tm-new-tiddler" title="This is newly created tiddler"  tags="{{$:/
status/UserName}} {{$:/tagword}}" text=<<now "Today is DDth, MMM YYYY">>/>
New Tiddler
</$button>


As you'll see, my tags are interpreted literally:
{{$:/status/UserName}} {{$:/tagword}}

Rather than as the transcluded values.

I'd also like to use the username in the title of the tiddler, but have the same lack-of-transclusion-activity problem.

I'm a bit stumped. Suggestions?

Thanks!

//steve.


BJ

unread,
Feb 18, 2017, 12:56:04 AM2/18/17
to tiddl...@googlegroups.com
like this:

\define new(user,newtag)
<$action-sendmessage $message="tm-new-tiddler" title="This is newly created tiddler"  tags=" [[$user$]] [[$newtag$]]" text=<<now "Today is DDth, MMM YYYY">>/>
\end


1 Make sure there is a username: {{$:/
status/UserName}}<br>


2 Select tag:
<$select tiddler='$:/newtag'>
<option>A Tale of Two Cities</option>
<option>A New Kind of Science</
option>
<option>The Dice Man</option>
</
$select>

3 Create tiddler with two tags

* username: {{$:/status/UserName}}
* newtag: {{$:
/newtag}}


4 Create new tiddler

<$button>
<$macrocall call $name="new" user={{$:/status/UserName}} newtag={{$:/newtag}}/>
New Tiddler
</$button>


All the best
BJ

Steven Schneider

unread,
Feb 18, 2017, 8:23:23 AM2/18/17
to TiddlyWiki
Thanks! Works perfectly. Much appreciated...

Following the ancient TiddlyWiki proverb -- Give a person some code and he'll be able to work for the day. Teach a person to code and he'll be able to answer the next post in the group" ---  it would be great to understand (though I'll probably get it eventually, and if it is too time-consuming to explain, that's fine):
Give a man a fish and you feed him for a day; teach a man to fish and you feed him for a lifetime.
Read more at: https://www.brainyquote.com/quotes/quotes/m/maimonides326751.htmlGive a man a fish and you feed him for a day; teach a man to fish and you feed him for a lifetime.
Read more at: https://www.brainyquote.com/quotes/quotes/m/maimonides326751.html

* What's the logic I was missing?

* Where did you come up with the <$macrocall call ...> syntax, and what does that do?


//steve.

BJ

unread,
Feb 18, 2017, 2:24:47 PM2/18/17
to TiddlyWiki
Hi Steve,
first I think everyone tries to write tw5 like you just did (I still do occasionally).

The first problem is that attributes to widgets must be either "xx" <<xx>> or {{xx}},  inside quotes the xx (eg {{tiddlername}})is treated  as an ordinary strings not as wikitext.

next you might try to use a 'join' macro that combines two strings like so:

<$action-sendmessage $message="tm-new-tiddler" title="This is newly created tiddler"  tags=<<join {{$:/status/UserName}} {{$:/tagword}}>> text=<<now "Today is DDth, MMM YYYY">>/>

Unfortunately tw5 does not allow expansion of transclusions as macro parameters, so this will not work.

What works well is to use macros to substitute text in wikitext (substitutions can go anywhere), so this is why I have used the macro defined as:


\define new(user,newtag)
<$action-sendmessage $message="tm-new-tiddler" title="This is newly created tiddler"  tags=" [[$user$]] [[$newtag$]]" text=<<now "Today is DDth, MMM YYYY">>/>
\end

You might be tempted to use the macro like:


<<new {{$:/status/UserName}} {{$:/newtag}}>>

However as I said above transclusions as macro parameters do not work, therefore we have to use the alternative way of using a macro, ie the macrocall widget, as the widget attributes do not suffer the same restriction as with the macro syntax.

Hope that makes things clearer.

In my own tiddlywikis I have a plugin to remove the restriction on macro parameters, as I got fed up with using macro this way!

cheers
Reply all
Reply to author
Forward
0 new messages