Open all tiddlers with the same tag

Is there a way to open all tiddlers with a tag at once? Ideally I’d like to change the behaviour of the tag pills themselves to close all tiddlers without their tag and open all with it at once (instead of showing the menu listing tagged tiddlers). But that is asking a lot. Something similar that gets halfway there might already help a lot, like for example ignoring the closing part and having a way to create a link that just opens all tiddlers with a specific tag.

2 Likes

I think this should work

<$button>
<$list filter='[tag[apple]]'>
<$action-navigate $to=<<currentTiddler>>/>
</$list>
Sesame
</$button>

You can style this as a tag pill but that doesn’t really make it a tag of course. To modify the real tag pills is more complex because they also contain a lot of other functionality, like the dropdown… and would you really want to disable that?

It works, thanks! Styling isn’t very important to me.

I would have disabled the dropdown if said ideal concept was possible, yes. I would create a TW where Tags are equivalent to “Pages” and Tiddlers can be part of multiple “Pages” by tagging. In this scenario, the dropdown would be obsolete: the list it provides is the same as the sidebar “Open” tab after switching to said “tag-page”.

Anyways, this already helps a lot and is as much as I dared to hope for. I’ll stick to a more default TW experience than I dreamed of and use this to open particular groups of tiddlers which only make sense together, but still should be seperate tiddlers.

Thank you lots and have a nice weekend : )

Hm, that’s a cool idea.

BTW, you may be interested in TiddlerSets.

1 Like

Seems interesting, I’ll see if it’s useful to me, thanks!

My informal package I have shared a few times “reimagine tags” includes open all, close all (tiddlers so tagged) and more additional features on every tag pill. perhaps install and harvest what you want.

reimagin-tags.json (16.6 KB)

There is also an Open all plugin, but is relatively limited.

1 Like

I also want tag pills to have the same behavior.

I’ve tried a lot of things but so far nothing has worked.

I know I have to make the click on tags edit $:/StoryList list field with the titles that have the tag, when users clicks on the tag pill.

Problem is: it seems I can’t do that with that kind of code:

{{{ [tag<myTag>] }}}

Quoting from the documentation (HTML in Wikitext):

Filtered attribute values are indicated with triple curly braces around a Filter. The value will be the first item in the resulting list, or the empty string if the list is empty.

What I have so far (but this only displays one tiddler with the clicked tag):

$:/core/ui/TagTemplate

\whitespace trim
<span class="tc-tag-list-item" data-tag-title=<<currentTiddler>>>
<$set name="transclusion" value=<<currentTiddler>>>
<$macrocall $name="tag-pill-body" tag=<<currentTiddler>> icon={{{ [<currentTiddler>] :cascade[all[shadows+tiddlers]tag[$:/tags/TiddlerIconFilter]!is[draft]get[text]] }}} colour={{{ [<currentTiddler>] :cascade[all[shadows+tiddlers]tag[$:/tags/TiddlerColourFilter]!is[draft]get[text]] }}} palette={{$:/palette}} element-tag="""$button""" element-attributes="""popup=<<qualify "$:/state/popup/tag">> dragFilter='[all[current]tagging[]]' tag='span'"""/>
</$set>
</span>

$:/core/macros/tag

(only the tag-pill-inner macro is modified)

\define tag-pill-styles()
background-color:$(backgroundColor)$;
fill:$(foregroundColor)$;
color:$(foregroundColor)$;
\end

<!-- This has no whitespace trim to avoid modifying $actions$. Closing tags omitted for brevity. -->
\define tag-pill-inner(tag,icon,colour,fallbackTarget,colourA,colourB,element-tag,element-attributes,actions)
<$vars
	foregroundColor=<<contrastcolour target:"""$colour$""" fallbackTarget:"""$fallbackTarget$""" colourA:"""$colourA$""" colourB:"""$colourB$""">>
	backgroundColor="""$colour$"""
><$element-tag$
	$element-attributes$
	class="tc-tag-label tc-btn-invisible"
	style=<<tag-pill-styles>>
><$set name="tiddlersWithThisTag" filter={{{ [tag<__tag__>] }}}><$action-setfield $tiddler="$:/StoryList" $field="list" $value=<<tiddlersWithThisTag>> /></$set>$actions$<$transclude tiddler="""$icon$"""/><$view tiddler=<<__tag__>> field="title" format="text" />
\end

\define tag-pill-body(tag,icon,colour,palette,element-tag,element-attributes,actions)
<$macrocall $name="tag-pill-inner" tag=<<__tag__>> icon="""$icon$""" colour="""$colour$""" fallbackTarget={{$palette$##tag-background}} colourA={{$palette$##foreground}} colourB={{$palette$##background}} element-tag="""$element-tag$""" element-attributes="""$element-attributes$""" actions="""$actions$"""/>
\end

\define tag-pill(tag,element-tag:"span",element-attributes:"",actions:"")
\whitespace trim
<span class="tc-tag-list-item" data-tag-title=<<__tag__>>>
<$let currentTiddler=<<__tag__>>>
<$macrocall $name="tag-pill-body" tag=<<__tag__>> icon={{{ [<currentTiddler>] :cascade[all[shadows+tiddlers]tag[$:/tags/TiddlerIconFilter]!is[draft]get[text]] }}} colour={{{ [<currentTiddler>] :cascade[all[shadows+tiddlers]tag[$:/tags/TiddlerColourFilter]!is[draft]get[text]] }}} palette={{$:/palette}} element-tag="""$element-tag$""" element-attributes="""$element-attributes$""" actions="""$actions$"""/>
</$let>
</span>
\end

\define tag(tag)
{{$tag$||$:/core/ui/TagTemplate}}
\end

It seems you want a completely different behaviour for your tags compared to normal tags, so maybe you should consider simply creating a new viewtemplate for your tiddlers, i.e a new “section” showing in all tiddlers, with a button that does what you want. And hide the tiddler template. - ?

If you want that, here’s a simple way to do it:

title:mybutton
tags: $:/tags/ViewTemplate
list-after: $:/core/ui/ViewTemplate/subtitle
text: (here you have your custom code for your button tags)

…and for $:/core/ui/ViewTemplate/subtitle you can just erase the tag $:/tags/ViewTemplate from it. (You can always delete it later to restore the tags field).

This seems like a lot of hassle for something I had hoped would be simpler.

Especially since I’m able to create a button that does that:

<$set name="tiddlersWithThisTag" filter="[tag[Fun]]">
<$button><$action-setfield $tiddler="$:/StoryList" $field="list" $value=<<tiddlersWithThisTag>> />
Update StoryList
</$button>
</$set>

I just can’t seem to do it with a variable tag. This does not work:

<$set name="myTag" value="Fun">
<$set name="tiddlersWithThisTag" filter={{{ [tag[<myTag>]] }}}>
<$button><$action-setfield $tiddler="$:/StoryList" $field="list" $value=<<tiddlersWithThisTag>> />
Update StoryList
</$button>
</$set>
</$set>

This version, done with tag=“HelloThere” for testing on TiddlyWiki.com seems to work.

There was an error – the filter attribute wants a filter, not the result of a filter. For operations on list fields, you generally want the action-listops widget rather than the setfield widget.

<$set name="myTag" value="HelloThere">
<$set name="tiddlersWithThisTag" filter="[tag<myTag>]">
<$button><$action-listops $tiddler="$:/StoryList" $field="list" $subfilter="[enlist<tiddlersWithThisTag>]" />
Update StoryList
</$button>
</$set>
</$set>

I just can’t seem to do it with a variable tag.

Maybe

<$button>
<$list filter='[tag[Fun]]'>
<$action-setfield
   $tiddler="$:/StoryList"
   $field="list"
   $value={{!!title}} 
/>
</$list>
Update StoryList
</$button>

Thank you sooo much @Mark_S!

I just woke up, ready to kind of give this up by using a workaround involving $:/DefaultTiddlers and tm-home. What a good surprise to see your solution, which had been here for 13h :smiley:

I just replaced $subfilter with $filter to have tiddlers completely replace, instead of them being appended.

Thanks again!

@twMat has a nice solution here
openalltagged TW 5.1.11 — (tiddlyspot.com)

I would also like to point out I shared my reimagine tags package earlier in this thread and suspect it has not being looked at;

  • Open all and Close all tagged items from the tag pills
  • Other features

I am happy seeing the diversity of answers and approaches but I am noticing an increase in “missed messages” in the forum of late.

Both shown below for clarity. Note: contains embedded SVG

Open all

<$button tooltip="Open all" class="tc-btn-invisible">
	<$list filter="[tag<currentTiddler>]">
		<$action-navigate $to=<<currentTiddler>> $scroll="no"/>
	</$list>
  <svg width="22pt" height="22pt" class="tc-clone-button tc-image-button" viewBox="0 0 128 128"><g fill=blue fill-rule="evenodd"><path d="M32.265 96v24.002A7.996 7.996 0 0040.263 128h79.74a7.996 7.996 0 007.997-7.998v-79.74a7.996 7.996 0 00-7.998-7.997H96V48h12.859a2.99 2.99 0 012.994 2.994v57.865a2.99 2.99 0 01-2.994 2.994H50.994A2.99 2.99 0 0148 108.859V96H32.265z"/><path d="M40 56h-7.993C27.588 56 24 52.418 24 48c0-4.41 3.585-8 8.007-8H40v-7.993C40 27.588 43.582 24 48 24c4.41 0 8 3.585 8 8.007V40h7.993C68.412 40 72 43.582 72 48c0 4.41-3.585 8-8.007 8H56v7.993C56 68.412 52.418 72 48 72c-4.41 0-8-3.585-8-8.007V56zM8 0C3.58 0 0 3.588 0 8v80c0 4.419 3.588 8 8 8h80c4.419 0 8-3.588 8-8V8c0-4.419-3.588-8-8-8H8zM19 16A2.997 2.997 0 0016 19.001v57.998A2.997 2.997 0 0019.001 80h57.998A2.997 2.997 0 0080 76.999V19.001A2.997 2.997 0 0076.999 16H19.001z"/></g></svg> Open all below
</$button>

Close all

<$button tooltip="Close all tagged except current" class="tc-btn-invisible">
	<$list filter="[tag<currentTiddler>] -[<storyTiddler>]">
		<$action-sendmessage $message="tm-close-tiddler" $param=<<currentTiddler>>/>
	</$list>
  <svg width="22pt" height="22pt" class="tc-close-all-button tc-image-button" viewBox="0 0 128 128"><g fill-rule="evenodd"><path d="M28 111.314l-14.144 14.143a8 8 0 01-11.313-11.313L16.686 100 2.543 85.856a8 8 0 0111.313-11.313L28 88.686l14.144-14.143a8 8 0 0111.313 11.313L39.314 100l14.143 14.144a8 8 0 01-11.313 11.313L28 111.314zM28 39.314L13.856 53.457A8 8 0 012.543 42.144L16.686 28 2.543 13.856A8 8 0 0113.856 2.543L28 16.686 42.144 2.543a8 8 0 0111.313 11.313L39.314 28l14.143 14.144a8 8 0 01-11.313 11.313L28 39.314zM100 39.314L85.856 53.457a8 8 0 01-11.313-11.313L88.686 28 74.543 13.856A8 8 0 0185.856 2.543L100 16.686l14.144-14.143a8 8 0 0111.313 11.313L111.314 28l14.143 14.144a8 8 0 01-11.313 11.313L100 39.314zM100 111.314l-14.144 14.143a8 8 0 01-11.313-11.313L88.686 100 74.543 85.856a8 8 0 0111.313-11.313L100 88.686l14.144-14.143a8 8 0 0111.313 11.313L111.314 100l14.143 14.144a8 8 0 01-11.313 11.313L100 111.314z"/></g></svg> Close all below
</$button>

Found this Andrew Harrison’s Plugin, just in case.

Alfonso

2 Likes

Yes that is what inspired my own which is part of a set. The difference being mine also opens system tiddlers with the tag.