How to apply a macro or a template to all the tag tiddlers?

45 views
Skip to first unread message

talha131

unread,
Sep 6, 2020, 11:17:02 AM9/6/20
to TiddlyWiki

I have a macro, which basically list all the tiddlers tagged with the current tiddler in a vertical tab list

\define tagVerticalTabsUnsorted(defaultTid:"")

@@float:right;
<span>
{{||$:/core/ui/TagTemplate}}
</span>
@@

<$macrocall $name="tabs" 
tabsList="[tag<currentTiddler>]"
default=<<__defaultTid__>>
state="$:/state/tab1" 
class="tc-vertical" 
template="$:/talha131/Template/VerticalTab"
retain="no"
/>

\end

How do I automatically apply it to all the tiddler that are a tag?

Say I create a new tag example. Then,

  1. A tiddler named example should automatically get created
  2. example tiddler should automatically show the tiddlers with the tag example in a vertical tab list
  3. If I edit the example tiddler with some other content then the vertical tag should stop showing. Instead it should the content I manually entered.

Is it possible in TW?

Eric Shulman

unread,
Sep 6, 2020, 11:42:56 AM9/6/20
to TiddlyWiki
On Sunday, September 6, 2020 at 8:17:02 AM UTC-7, talha131 wrote:
I have a macro, which basically list all the tiddlers tagged with the current tiddler in a vertical tab list 
How do I automatically apply it to all the tiddler that are a tag?
Say I create a new tag example. Then,
  1. A tiddler named example should automatically get created
  2. example tiddler should automatically show the tiddlers with the tag example in a vertical tab list
  3. If I edit the example tiddler with some other content then the vertical tag should stop showing. Instead it should the content I manually entered.
Try this:

1) Create a tiddler (e.g, "TagTabs"), tagged with $:/tags/ViewTemplate, containing: 
<$list filter="[tag<currentTiddler>limit[1]]" variable="is_a_tag">
<$list filter="[<currentTiddler>!has[text]]" variable="has_no_text">


<$macrocall $name="tabs"
tabsList="[tag
<currentTiddler>]"

default=<<__defaultTid__>>
state="$:/state/tab1"
class="tc-vertical"
template="$:/talha131/Template/VerticalTab"
retain="no"
/>

</$list>
</$list>

Notes:
* Tagging this tiddler with $:/tags/ViewTemplate adds the content to every tiddler
* The first $list checks to see if the current tiddler is a tag
* The second $list checks to see if the current tiddler has a blank text field
* If both conditions are met, then the <$macrocall> is shown, otherwise nothing is shown

enjoy,
-e


talha131

unread,
Sep 6, 2020, 3:16:13 PM9/6/20
to TiddlyWiki

Genius solution Eric!

Reply all
Reply to author
Forward
0 new messages