Hello,
I wanted to make a button that adds a tag to a tiddler when pressed.
I googled a bit and found some code from 2013
This was in a thread entitled
[TW5] - Is it possible to toggle a tag with a button?
It had this code
<$fieldmangler>
<$list filter="[is[current]tag[MeTag]]">
<$button message="tw-remove-tag" param="MeTag">remove MeTag</$button>
</$list>
<$list filter="[is[current]!tag[MeTag]]">
<$button message="tw-add-tag" param="MeTag">add MeTag</$button>
</$list>
</$fieldmangler>
Not quite what I wanted so I changed to this:
<$fieldmangler>
<$button>
<$action-sendmessage $message="tm-add-tag" param="my tag"/>
click to add tag
</$button>
</$fieldmangler>
But this didn't work -- more searching ... and I changed it to this:
<$fieldmangler>
<$button>
<$action-sendmessage $message="tm-add-tag" $param="my tag"/>
click to add tag works
</$button>
</$fieldmangler>
The *only* difference is 'param' has become '$param'
What about the documentation?
Says the argument should be 'param' so it agrees with the 2013 TW but not the current TW.
So is the documentation correct and the
implementation wrong - or vice versa?
I know this is a terribly small change 'param' vs '$param' but for a beginner like me these discrepancies are very difficult to recognise and pin down.
When stuff doesn't work as advertised I use my beginner strategy
1) search for an example
2) cut and paste
3) pray
And it's *very* frustrating to find old code (which did work in 2013) which does not
work today (this is a symptom of a much deeper problem which actually Transclusion and non-mutable
data solves, but I won't bore you with the deatils here) - this is the point where many beginners
give up - they do so silently and don't flood forums with questions - so we never know why
they gve up or when - we just have to guess.
It seems like "$" attribute names are fixed and any other names can be chosen by the user.
I've seen 'param' mentioned all over the place at
tiddlywiki.com - should it be '$param' everywhere????
When did the names change and why?
Cheers
/Joe