New here button question: current title plus suffix

For a new here button, I want to create three $action-sendmessage actions, to create three child tiddlers, title + comms, title + notes, title + sources. How do I specify for each one that the new tiddler will have the title of the current tiddler plus the suffix?

Do you want to generate all three tiddlers with a single button? If so, I think the most efficient way to do this is with a list:

<$list filter="comms notes sources" variable=suffix>
	<$action-sendmessage $message="tm-new-tiddler" title={{{ [<currentTiddler>] [<suffix>] +[join[ ]] }}} />
</$list>
  • Note that I used variable=suffix to prevent the $list from redefining <<currentTiddler>>, as it will otherwise do by default. This lets us use <currentTiddler> to refer to the actual current tiddler within the list.

If you want three separate buttons, here’s what the action widget would look with a hard-coded suffix in place of the variable:

<$action-sendmessage $message="tm-new-tiddler" title={{{ [<currentTiddler>] comms +[join[ ]] }}} />

If you’re using 5.3.0+, you can also use a substituted attribute value in place of the filter transclusion if you prefer the shorter syntax. Note the backticks in place of quotes and the $(variable)$ syntax.

<$action-sendmessage $message="tm-new-tiddler" title=`$(currentTiddler)$ comms` />

You could also use the backtick syntax within the list widget:

<$list filter="comms notes sources" variable=suffix>
	<$action-sendmessage $message="tm-new-tiddler" title=`$(currentTiddler)$ $(suffix)$` />
</$list>

Thanks @etardiff. I used your first ‘single button’ option, and I wrapped it with <$button> and </$button>, and it works great. The only issue is that I added Tabs+ as the button text, but it shows as Tabs+ Tabs+ Tabs+ Tabs+ in the viewtoolbar. Any way to make it just show the button text once?

Make sure that any text you want to display is outside the $list widget! I suspect that’s why you’re seeing the duplication.

Ah shoot, another complication: I need to add other parameters to the three resulting tiddlers. Specific captions and text. I was hoping for something like

button
action message 1 new
action message 2 new
action message 3 new
>Tabs+
</button>

No, I had the text between the ending $list tag and the ending $button tag.

Okay here is what I came up with. Thanks @etardiff, I couldn’t have done it without you!

<$button class="tc-btn-invisible"><$action-sendmessage $message="tm-new-tiddler" title={{{ [<currentTiddler>] comms +[join[ ]] }}} caption="comms" text="<$link/>" tags="comms" />
<$action-sendmessage $message="tm-new-tiddler" title={{{ [<currentTiddler>] notes +[join[ ]] }}} caption="notes" text="<$link/>" tags="notes" />
<$action-sendmessage $message="tm-new-tiddler" title={{{ [<currentTiddler>] sources +[join[ ]] }}} caption="sources" text="<$link/>" tags="sources" />Tabs+</$button>

A very slightly different approach, using addsuffix instead of join, written before your last post, but without time to send.

title: MyTemplate
tags: $:/tags/ViewTemplate

<% if [<currentTiddler>tag[MyTag]] %>
<$button>Tags+
  <$action-sendmessage $message="tm-new-tiddler" title={{{ [<currentTiddler>addsuffix[ comms]] }}} tags="Comms" text="Add comms info here"/>
  <$action-sendmessage $message="tm-new-tiddler" title={{{ [<currentTiddler>addsuffix[ notes]] }}} tags="Notes" text="Add notes info here"/>
  <$action-sendmessage $message="tm-new-tiddler" title={{{ [<currentTiddler>addsuffix[ sources]] }}} tags="Sources" text="Add sources info here"/>
</$button>
<% endif %>

MyTemplate.json (653 Bytes)

Thanks, @Scott_Sauyet , I imagine you mean ViewToolbar rather than ViewTemplate.

No. I didn’t know how you were using it when I wrote it. I probably should have removed that part before posting. But I just used a ViewTemplate to add the button to the tiddler body. The point is the <button> widget.

Okay, one other problem:

In the tiddlers that appear as tabs, I have <$link/> so that I can open them from the tabs macro in the parent tiddler. But the link is showing as a link to the parent tiddler. How do I avoid this?

The <<tabs>> macro doesn’t change the value of currentTiddler within the displayed tabs so references to <<currentTiddler>> (or implied references as when using “<$link/>”) refer back to the tiddler in which the <<tabs>> macro is defined (a.k.a, “the parent tiddler”).

Within the rendered tabs, you can refer to the name of the tiddler from which an individual tab’s content originates by using <<currentTab>>, like this:

<$link to=<<currentTab>>/>

Note that, when this link is rendered outside of a tab (i.e., by viewing the tiddler directly in the StoryRiver), the value of <<currentTab>> is undefined so the above syntax is handled as if you had entered <$link/>, which results in a self-referential link to itself.

enjoy,
-e

Thanks Eric! World domination is even closer to completion!

1 Like

My deepest gratitude to all who helped me today!

If anyone wants to the see the final results, see 2025 Bible notes.

Blessings and thanks again!

1 Like

Very clean and intuitive as always! :clap:

If you don’t generally want to edit the tab tiddlers when they’re initially created, you could replace your $action-sendmessage widgets with $action-createtiddler, which will create the tiddlers silently in the background, so you don’t have to save each draft manually to make the tab “live”. Here’s an example of the replacements you’d need to make:

<$action-createtiddler
	$basetitle={{{ [<currentTiddler>] comms +[join[ ]] }}}
	caption="comms"
	tag="notes"
	text="<$link to=<<currentTab>>/>" />

And (I’m sorry, I love lists!) since your caption/tag values are all based on the tab title, you could also replace all three action widgets with a $list if you so choose:

<$button class="tc-btn-invisible">
<$list filter="comms notes sources" variable=type>
<$action-createtiddler
	$basetitle={{{ [<currentTiddler>] [<type>] +[join[ ]] }}}
	caption=<<type>>
	tags=<<type>>
	text="<$link to=<<currentTab>>/>"
/>
</$list>
Tabs+
</$button>

Good luck with your note-taking!

Ooh! That’s nice. I would have tried your list approach before but it didn’t let me add the other fields. Now that you have shown me how to do it, I will change my code to this example. I was almost going to ask about automatically closing the tiddlers upon creation but you beat me to it. Thanks!

[edit: the file is now updated with Emily’s code. Nice improvement]

I like the idea of easily adding tabs to tiddlers for additional content.

So I am working on a solution that allows you programaticaly set a variable, provide a list of tab tiddlers, and if set will display those tabs on the tiddler. Thus it can be set in the view template, or a tiddler field, and they will be displayed on any relavant tiddler when it has a value.

Similarly a tabs field, that can list tab tiddlers which will also be displayed on the current tiddler and/or merged with those from the above variable.

In the above there will be a default position and a before and after the text field position. In reality there may be three tiddlers in the view template to achive this.

Of note:

Unlike @DaveGifford request these tab tiddlers are reusable content, within them for example they may allow one to edit [<currentTiddler>] [[-]] [<currentTab>] +[join[]] but not create them until you do so. As a result these utility tiddlers do not get created until meaningful infomation is provided. For a given tiddler.

  • I may look at providing a generic solution for creating tab related tiddlers based on current tiddler.
  • For example in @DaveGifford current request one may set in the view template system $:/mytabs/comms, $:/mytabs/notes, $:/mytabs/sources which have the captions comms, notes and sources and includes those tabs in the relavant tiddlers.

Advanced

  • I will need to find a strategy to set the order of such tabs, and idealy away to reorder on a specific tiddler or set of tiddlers.

Let me know if you have any questions or ideas, but what I am trying todo is provide a flexible and general solution to custom tabs on tiddlers.

Wow Tones, that sounds like a nice tool! Looking forward to checking it out after you get the last bits in place.