New tiddler button question

Hi everyone

I tried adding tags="note" to the following snippet, but it seems I can only do one tag or the other. Is there a way around this? I need the button to tag the new tiddler as “note” but also as the title of the tiddler from which I am creating it.

<$button class="tc-btn-invisible"><$action-sendmessage $message="tm-new-tiddler" tags={{{ [{!!title}format:titlelist[]] }}} /> ^^{{$:/core/images/new-button}}^^</$button>

<$button class="tc-btn-invisible"><$action-sendmessage $message="tm-new-tiddler" tags={{{ [{!!title}format:titlelist[]] [[note]] :and[join[ ]] }}} /> ^^{{$:/core/images/new-button}}^^</$button>

1 Like

Thanks Saq! Blessings.

@DaveGifford the solution @saqimtiaz introduces overcomes the issue you face by using the message <$action-sendmessage $message="tm-new-tiddler". This is because the only way you have to address the “tags field” is as a raw fieldname. @saqimtiaz’s solution effectively constructs the tags field from more than one value. This is the best solution (and simplest) by far if your button remains very simple.

Did you realise you are almost doing the same as the new here button?, it uses a similar way. You could have cloned it and changed the set name=tags value, see $:/core/ui/Buttons/new-here

  • The advantage being it can be selected in the toolbars etc…
  • You can change all the $:/language references to text, or change the icon (in two places)

if however you use the action-createtiddler widget instead you can use it to wrap additional action widgets within it. Here I keep it exactly like the original request.

  • I assume your button included title="New subTiddler" or similar.
<$button>
<$action-createtiddler $basetitle="New subTiddler" text={{new-tiddler-text}} tags="note">
   <$action-listops $tiddler=<<createTiddler-title>> $field="tags" $subfilter="[<currentTiddler>] [[another tag]]" />
</$action-createtiddler>
Create subTiddler
</$button>
  • Notice how I initially set tags to note, this is ok because its a literal string without space.
    • But it also could be in the actionlistops widget.
  • I then use actionlistops to add additional tags, you could have multiple list ops widget even conditional ones.
  • The above solution will not appear superior, unless you want to do more with your new tiddler including;
    • Add other fields/actions on to the <<createTiddler-title>> or <<currentTiddler>>
    • Add the new tiddler title to a list inside the parent tiddler, rather than the tags.
    • Navigate to it OR Open it in draft mode
    • Add other actions to the button eg log tiddler creation.

Warnings;

  • “Action send messages” inside the action-createtiddler is painful because you can’t specify the tiddler and $fieldmangler may be needed. All other actions are fine.

Thanks Tones for this helpful explanation! I will bookmark this for reference.