How to transclude buttons by filtered transclusion

I have some buttons which I have tagged with tag btn-clips. I can list them using this code as shown here

{{{ [tag[btn-clips]] }}}

How to transclude these buttons (instead of listing their links) in a single line using filtered transclusion like this ?

Hi @arunnbabu81,

I did not test this, but filtered transclusions can use templates, so I think I would first create a template tiddler named myTemplate containing:

<$transclude/>

and then somewhere else:

{{{ [tag[btn-clips]]||myTemplate }}}

Have fun,

Fred

1 Like

Thank you @tw-FRed. It works perfectly.

Previously I used to transclude each of these buttons individually like this {{||buttons1}} {{||button2}} in the tiddlerinfo fields tiddler. So whenever I pressed on these buttons, new fields were getting added to the currentTiddler. But now since I am using the above mentioned filtered transclusion by template, on pressing these buttons - fields are getting added to the button tiddlers instead of being added to the currentTiddler. Any way to solve this ?

Replace the template code with:

<$list filter="[tag[btn-clips]]" variable="button">
<$transclude tiddler=<<button>>/>
</$list>

Then in your target tiddler replace {{{ [tag[btn-clips]]||myTemplate }}} with {{||myTemplate}}

Fred

@arunnbabu81 I am sure @tw-FRed’s solution is more than adequate but if you wanted to retain the ability to provide the transclusion with a filter you can make use of the <<storyTiddler>> variable, which usually contains the same value as <<currentTiddler>> but is less likely to be modified by other lists etc…

The template would then be;

<$let targetTiddler=<<currentTiddler>> >
<$tiddler tiddler=<<storyTiddler>> >
<$transclude tiddler=<<targetTiddler>>/>
</$tiddler>
</$let>

And calling remains the same

{{{ [tag[btn-clips]]||myTemplate }}}
2 Likes

Oh, I will just add

  • putting mode=block in the transclusion widget is wise for transcluding whole tiddlers.
  • A good feature of this type of template is the following forms all work
    • The aforementioned {{{ [tag[btn-clips]]||myTemplate }}}
    • {{{ [[HelloThere]]||template}}} or list o tiddlers
    • {{{HelloThere||template}}} undelimited title
    • But also the output of any filter, see below;
    • be aware if a “filtered transclusion” is used as an attribute, eg; is proceeded by = only the first result is returned.

Because the list of titles can be a filter, any filter that generates a title or a list of titles can be used. For example using the enlist

Post script;

  • Also writing macros to accept a filter, not just a single title is also smart.

Thank you @TW_Tones. That’s is working in my short testing.

Thanks for the advice. I will have to read carefully to understand it. I have bookmarked this for later reading.

The main thing is to use the template I provided and then you can use the template in a number of ways as illustrated, no need to know how it works, for now.

1 Like