Filtering tags (tagging operator)

I can’t find how filter a list of tag, I want remove the tags that aren’t been used. I tried different ways with/without filter operator(/run prefix) but it doesn’t work. I must have missed something. I also try it with !is[blank]
Example:

  • one tiddler tagged with $:/tags/Macro
  • two tiddler tagged with $:/tags/Stylesheet

I used the following code:

\define zerotagging() [tagging[]count[]!match[0]]
<$list filter="[all[shadows]tags[]is[system]filter<zerotagging>sort[title]]" variable="sysTag">
	<<sysTag>>
	<$list filter="[tag<sysTag>]" variable="tid">
		<br><$text text=<<tid>>/>
	</$list>
	<br>
</$list>

The output is all system tag with the three tiddlers in their respectives tags. But I want only the tags of this tiddler.

Is it possible do it only with filters?

I’m having trouble understanding what you want. Perhaps you could give an example of the output that you want?

How a tag is not used? I mean a title or a tiddler is tag if and only if it appears at least in one tiddler tags field? So, how a tag is not used?

Do you mean a tiddler with no tagging e.g. no any other tiddler has been tagged with it?

[[task]tagging[]]
→ same as [tag[task]]
1 Like

Sorry for my bad explanation.

I think that can be better simplify the code and the same tiddlers (1 macro and 2 stylesheet).

<$list filter="[all[shadows]tags[]is[system]sort[title]]">
	<$link/>
</$list>

This return all system tags. But I want only $:/tags/Macro and $:/tags/Stylesheet becuase they are the ones that I used in my tiddlers. Here the output would be:

$:/tags/Macro
$:/tags/Stylesheet

I am not able to find the filter expression that works. I want a final output something like:

$:/tags/Macro
Macro1

$:/tags/Stylesheet
Style1
Style2
<$list filter="[[$:/tags/Macro]] [[$:/tags/Stylesheet]]">
<dl>
<dt><$link/></dt>
<dd><$list filter="[all[tiddlers+shadows]tag<currentTiddler>]" template="$:/core/ui/ListItemTemplate"/></dd>
</dl>
</$list>

This will list all tiddlers tagged with the tags you want. If you only want the tiddlers you made, you can remove the all[tiddlers+shadows] part (I added Description Details element for formatting).

Here I “hard-coded” the tags but you could use a more complex filter like

[tags[]creator{$:/status/UserName}]

To list all the tags you created + their respective tiddlers.

1 Like

Shadow tiddlers only come from plugins. Are your tiddlers in plugins?

Thanks @telumire , but in my example we know the tags and the tiddlers. But I have looking for the general case when we need the system tags that are been used and the tagged tiddler.

@Mark_S , in principle they wouldn’t be.

The context:
The idea is create a solution for The problem with "custom solutions" . I have started working on the part of system tags. I don’t want display all tags if they aren’t been used.

Then you can use [is[system]tags[]]. It will list all tags used by system tiddlers.

EDIT : or [all[shadows+tiddlers]is[system]tags[]] if you want to include tags from plugins.

EDIT 2 : correction, the correct filter to get system tags is [tags[]is[system]] and [all[shadows+tiddlers]tags[]is[system]] for the complete list

I think you’re asking for the set of tiddlers that are not system tiddlers but are tagged by system tiddlers.

<$vars filt="[tagging[]!is[system]count[]!match[0]]">
<$list filter="[all[shadows+tiddlers]filter<filt>]">
<dt><$link to=<<currentTiddler>>>''<$text text=<<currentTiddler>>/>''</$link> : 
<$list filter="[<currentTiddler>tagging[]]" >
<dd><<currentTiddler>></dd>
</$list>
</dt>
</$list>
</$vars>
1 Like

@Mark_S , its output is empty

Thaks folks for your time. But I think I didn’t simplify enough the question before exposing it.




:arrow_right: Reexplaining my issue

{{{ [all[shadows]tags[]is[system]sort[title]] }}}

return the list of (all) system tags. It a long list.

$:/tags/AboveStory
$:/tags/Actions
$:/tags/AdvancedSearch
...
...
...
$:/tags/ViewTemplateBodyFilter
$:/tags/ViewTemplateTitleFilter
$:/tags/ViewToolbar

I want to filter the list to get only the system tags that are been used in tiddlers.

One example case could be:

  • 3 tiddler.
  • two of them have the tag $:/tags/Stylesheet
  • the other has the tag $:/tags/Macro

I am looking for the filter that returns

$:/tags/Macro
$:/tags/Stylesheet

I think it would be like something like the following code, but it doesn't work.
{{{ [all[shadows]tags[]is[system]sort[title]] :filter[tagging[]count[]!match[0]] }}}

[all[shadows]tags[]is[system]sort[title]] :filter[tagging[]is[tiddler]]

2 Likes

Thanks @saqimtiaz . It works perfectly

@Alvaro good to see you have an answer. Keep in mind the difference between tiddlywiki.com and empty.html Very few if these system tags are in use in empty.html while tiddlywiki.com is a place we read and test thing by way of the documentation and examples many “system tags” are in use.

Also, apart from choosing “shadows or tiddlers” you can always determine if it is a system tiddler, but this can also translate to prefix[$:/] as well.

@saqimtiaz’s elegant solution is testing “[is[tiddler]]” which means when a tiddler is a shadow tiddler but it is an overwritten one. Overwritten relative to the $:/core or plugin it originated from. This is a good proxy to your request;

Perhaps this could be better stated as;

I want to filter the list to get only the system tags that are been used in [non-system] tiddlers.

I know it seems like a subtle point in the use of words, but it is important in our/your long term understanding of Tiddlywiki and to help you communicate your needs to others here.

However “No question is a stupid question, no matter how many times you ask”.

@TW_Tones , you are right. These and other point that change their “visibility” when we are in the point of view of who needs the help or the helper.

Yes, and the person who needs help not only needs a solution, but the knowledge needed to find future solutions or at least to ask the “best Questions” they can.

As a prolific volunteer in Discourse I Am very happy to help, but if, “when I help”, I try and give useful and answers to future possible questions, or better ways to ask questions, through education, I have more time to answer more questions.