The tag is being added to the tiddler from which the code is launched. You 
might not even notice it unless you find your expected tag counts being 
thrown off.

Have fun!
-- Mark

On Friday, March 16, 2018 at 8:23:32 PM UTC-7, Michael Wiktowy wrote:
>
> Thanks so much for finding this work-around! I got it to work with my 
> application (soon to be put somewhere public). I didn't think to use both 
> action triggers to make things fire sequentially and would have guessed 
> that the <$button actions> would execute second. It still seems like 
> something isn't right here. I did not see the double actions that you 
> witnessed or maybe, in my case, it really didn't matter if the same tag was 
> (re)added twice.
>
> /Mike
>
> On Friday, March 16, 2018 at 7:27:38 PM UTC-4, Mark S. wrote:
>>
>> This seems to work:
>>
>> \define actions()
>> <$set name=cstContents value={{$:/temp/$(dbname)$DBedit}}>
>> <$tiddler tiddler=<<cstContents>>>
>> <$fieldmangler>
>> <$action-sendmessage $message="tm-add-tag" $param={{$:/temp/$(dbname)
>> $DBedit!!current_tag}}/>
>> </$fieldmangler>
>> </$tiddler>
>> </$set>
>> \end
>> \define currentStateTid() $:/temp/$(dbname)$DBedit
>>
>> <$set name="dbname" value="some_database">
>> <$button actions=<<actions>>>
>> <$action-createtiddler $basetitle=<<dbname>> $savetitle=<<currentStateTid
>> >>/>
>>
>> {{$:/core/images/new-button}}</$button>
>> </$set>
>>
>> It takes advantage of the fact that there are now 2 ways to invoke 
>> actions with a button (the content, and the "actions" string). Apparently 
>> the "actions" string gets run after the contents.
>>
>> BUT, there's still one weird thing. The "actions" string appears to get 
>> run twice - with one extra time for tiddler where the code is invoked. In 
>> other words, the calling tiddler also gets tagged. Maybe someone can work 
>> that one out.
>>
>> HTH
>> -- Mark
>>
>>
>> On Friday, March 16, 2018 at 12:54:22 PM UTC-7, Michael Wiktowy wrote:
>>>
>>> Hi,
>>>
>>> I am not sure if I am doing something wrong or if there is some sort of 
>>> race condition with tiddler actions being evaluated but here is my example:
>>>
>>> \define currentStateTid() $:/temp/$(dbname)$DBedit
>>>
>>> <$set name="dbname" value="some_database">
>>> <$button>
>>> <$action-createtiddler $basetitle=<<dbname>> $savetitle=<<
>>> currentStateTid>>/>
>>> <$wikify name="state_tiddler_content" text="<$view 
>>> tiddler=<<currentStateTid>> />">
>>> <$fieldmangler tiddler=<<state_tiddler_content>>>
>>> <$action-sendmessage $message="tm-add-tag" $param={{!!current_tag}}/>
>>> </$fieldmangler>
>>> </$wikify>
>>> {{$:/core/images/new-button}}</$button>
>>> </$set>
>>>
>>> When you paste this into a new tiddler and add a field "current_tag" 
>>> with something in it you will end up with a tiddler with a plus button.
>>> Clicking the button will add a new tiddler with the name referencing the 
>>> variable dbname = "some_database". If that already exists, a number is 
>>> added/incremented accordingly.
>>>
>>> So far, so good.
>>>
>>> I want to then add a tag to the created tiddler using the contents of 
>>> the "current_tag" field. However, since I don't know what the created 
>>> tiddlers name is beforehand, I am referencing the content of the $savetitle 
>>> from the previous $action-createtiddler. When you do this though, it seems 
>>> to add the tag to the tiddler that was in <<state_tiddler>> *previously* 
>>> ... as if the tm-add-tag message gets processed before the 
>>> $action-createtiddler can set the <<state_tiddler>> to the new value.
>>>
>>> I have thought of using the tags option in $action-createtiddler so I 
>>> don't have to know the resulting tiddler name but the tag in current_tag 
>>> has spaces and needs to be appended to a bunch of other tags coming from 
>>> some other template and dealing with passing around the required "[[tag 
>>> with spaces]]" has been proving painful. The closest that I have gotten is 
>>> to add a bunch of tags with each of them the words in "current_tag" 
>>> eventhough the [[]] characters are being passed.
>>>
>>> Is this a bug or am I doing something wrong?
>>>
>>> /Mike
>>>
>>>

-- 
You received this message because you are subscribed to the Google Groups 
"TiddlyWiki" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/tiddlywiki.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/tiddlywiki/6d2bbe3e-f48a-4aab-a821-742edcd6e9fb%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to